From ce4a32fe52ef09d8f5ff1dd22c001110902b60a2 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kstyles/keramik/genembed.cpp | 387 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 387 insertions(+) create mode 100644 kstyles/keramik/genembed.cpp (limited to 'kstyles/keramik/genembed.cpp') diff --git a/kstyles/keramik/genembed.cpp b/kstyles/keramik/genembed.cpp new file mode 100644 index 000000000..2f9449406 --- /dev/null +++ b/kstyles/keramik/genembed.cpp @@ -0,0 +1,387 @@ +/** +A small utility to generate embedded images for Keramik, especially structured for easy recoloring... + +Copyright (c) 2002 Maksim Orlovich + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +*/ + +#include +#include +#include +#include +#include +#include + +#include + +#include +using namespace std; + +#include +#include + +//NOTE: Use of old-style header is intentional for portability. See revisions 1.6 and 1.7 + +//Force-touch-embedded-revision: 2 + +#include "keramikimage.h" + +/** +Need to generate something like this: +TargetColorAlpha, GreyAdd, SrcAlpha; + +so that one can do (R*T+GreyAdd, G*T+GreyAdd, B*T+GreyAdd, SrcAlpha) as pixel values +*/ + + +int evalSuffix(QString suffix) +{ + if (suffix == "-tl") + return 0; + + if (suffix == "-tc") + return 1; + + if (suffix == "-tr") + return 2; + + if (suffix == "-cl") + return 3; + + if (suffix == "-cc") + return 4; + + if (suffix == "-cr") + return 5; + + if (suffix == "-bl") + return 6; + + if (suffix == "-bc") + return 7; + + if (suffix == "-br") + return 8; + + if (suffix == "-separator") + return KeramikTileSeparator; + + if (suffix == "-slider1") + return KeramikSlider1; + + if (suffix == "-slider2") + return KeramikSlider2; + + if (suffix == "-slider3") + return KeramikSlider3; + + if (suffix == "-slider4") + return KeramikSlider4; + + if (suffix == "-groove1") + return KeramikGroove1; + + if (suffix == "-groove2") + return KeramikGroove2; + + if (suffix == "-1") + return 1; + + if (suffix == "-2") + return 2; + + if (suffix == "-3") + return 3; + + return -1; +} + + +int main(int argc, char** argv) +{ + if (argc < 2) + return 0; + + QValueVector images; + + cout<<"#include \n\n"; + cout<<"#include \"keramikimage.h\"\n\n"; + + QMap assignID; + int nextID = 0; + + for (int c = 1; c(strdup(s.latin1())); + + + bool reallySolid = true; + + int pixCount = 0; + int pixSolid = 0; + + cout<<"static const unsigned char "<(input.bits() ); + int size = input.width()*input.height(); + + for (int pos=0; pos(input.bits() ); + for (int pos=0; pos0 || v > 128) + { //Non-shadow + float fv = v/255.0; + fv = pow(fv, gamma); + v = int(255.5*fv); + + + if (s<17 && highlights) //A bit of a highligt.. + { + float effectPortion = (16 - s)/15.0; + + greyAdd = (int)(v/4.0 * effectPortion*1.2); + targetColorAlpha = v - greyAdd; + } + else + { + targetColorAlpha = v;//(int)(fv*255); + greyAdd = 0; + } + } + else + { + if (shadows) + { + targetColorAlpha = 0; + greyAdd = v; + } + else + { + targetColorAlpha = v;//(int)(fv*255); + greyAdd = 0; + } + } + + greyAdd+=brightAdj; + + if (reallySolid) + cout< images;\n"; + cout<<"};\n\n"; + cout<<"KeramikImageDb* KeramikImageDb::instance = 0;\n\n"; + + cout<<"KeramikEmbedImage* KeramikGetDbImage(int id)\n"; + cout<<"{\n"; + cout<<"\treturn KeramikImageDb::getInstance()->getImage(id);\n"; + cout<<"}\n\n"; + + cout<<"void KeramikDbCleanup()\n"; + cout<<"{\n"; + cout<<"\t\tKeramikImageDb::release();\n"; + cout<<"}\n"; + + + + + QFile file("keramikrc.h"); + file.open(IO_WriteOnly); + QTextStream ts( &file); + ts<<"#ifndef KERAMIK_RC_H\n"; + ts<<"#define KERAMIK_RC_H\n"; + + ts<<"enum KeramikWidget {\n"; + for (QMap::iterator i = assignID.begin(); i != assignID.end(); ++i) + { + QString name = "keramik_"+i.key(); + name.replace("-","_"); + ts<<"\t"<