summaryrefslogtreecommitdiffstats
path: root/noatun/modules/kjofol-skin/helpers.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commite2de64d6f1beb9e492daf5b886e19933c1fa41dd (patch)
tree9047cf9e6b5c43878d5bf82660adae77ceee097a /noatun/modules/kjofol-skin/helpers.cpp
downloadtdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.tar.gz
tdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.zip
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/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'noatun/modules/kjofol-skin/helpers.cpp')
-rw-r--r--noatun/modules/kjofol-skin/helpers.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/noatun/modules/kjofol-skin/helpers.cpp b/noatun/modules/kjofol-skin/helpers.cpp
new file mode 100644
index 00000000..b38822a6
--- /dev/null
+++ b/noatun/modules/kjofol-skin/helpers.cpp
@@ -0,0 +1,64 @@
+/***************************************************************************
+ helpers.cpp
+ Just a few functions needed in several Kjofol-classes
+ ---------------------------------------------
+ Maintainer: Charles Samuels <charles@kde.org>
+
+ ***************************************************************************/
+
+#ifndef KJHELPERS_CPP
+#define KJHELPERS_CPP
+
+static int grayRgb(QRgb r)
+{
+ return qGray(qRed(r), qGreen(r), qBlue(r));
+}
+
+static int isGray(QRgb r)
+{
+// this is more tolerant than the old version
+// i.e. RGB 162 163 162 is treated as gray too
+// too many broken skins around having such colors
+
+// cerr << "r("<<qRed(r)<<","<<qGreen(r)<<","<<qBlue(r)<<")"<<endl;
+
+ if ( (qRed(r)==qGreen(r)) || (qRed(r)+1==qGreen(r)) || (qRed(r)-1==qGreen(r)))
+ {
+ if ( (qRed(r)==qBlue(r)) || (qRed(r)+1==qBlue(r)) || (qRed(r)-1==qBlue(r)))
+ {
+ // looks a bit like gray, so return true
+ return (1);
+ }
+ }
+ // well, it's not gray
+ return(0);
+
+/*
+ // mETz: wrong braces in the code below ??
+ return (qRed(r)==qGreen(r)) && (qRed(r) == qBlue(r));
+*/
+}
+
+// only works little endian
+// UPDATE: should work on both little and big endian now (haven't tested that!)
+// this code is taken from the QT-docu and I hope that this example
+// is one of the working ones ;)
+inline void setPixel1BPP(QImage &image, int x, int y, bool value)
+{
+ if ( image.bitOrder() == QImage::LittleEndian )
+ {
+ if (value)
+ *(image.scanLine(y) + (x >> 3)) |= 1 << (x & 7);
+ else
+ *(image.scanLine(y) + (x >> 3)) &= ~(1 << (x & 7));
+ }
+ else
+ {
+ if (value)
+ *(image.scanLine(y) + (x >> 3)) |= 1 << (7-(x & 7));
+ else
+ *(image.scanLine(y) + (x >> 3)) &= ~(1 << (7-(x & 7)));
+ }
+}
+
+#endif