[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Keramik style and colorizing (was: Re: kde 3.1 -- make Keramik default?)
From:       Allan Sandfeld Jensen <snowwolf () one2one-networks ! com>
Date:       2002-06-12 9:32:59
[Download RAW message or body]

Oh well. I might as well post it.

Yes I know, this is The Wrong Way(TM), but it is proff of concept and it 
works.

Apparently it is this line that break color schemes:
if ( hue >= 0 && h >= 0 ) h = ( h + 144 + hue ) % 360;

(There is no way grey + white should give light blue as it does now)

I have no ksnapshot at the moment so screenshots will have to wait.

greetings
`Allan

On Wednesday 12 June 2002 02:12, Allan Sandfeld Jensen wrote:
>
> Actually to be a little more constuctive, I have looked into what puts the
> colors off. It apparently happens in converting between hsv and rgb + it
> doesnt use the same formula for colorizing as kiconeffects.
> I have made a patch that uses the formula from kiconeffects.cpp to
> calculate the hue and still the keramik formula for sat and val. It works
> okey, the biggest problem is that the base pixmaps should be recolored as
> they are way to light if you respect color schemes. (The KDE default color
> schemes is grey, when applying light pixmaps this becomes very white'ish).
> OTOH dark color schemes look great with keramik now, especially atlas looks
> really cool.
>

["wrong.patch" (text/x-diff)]

? wrong.patch
Index: pixmaploader.cpp
===================================================================
RCS file: /home/kde/kdelibs/kstyles/keramik/pixmaploader.cpp,v
retrieving revision 1.26
diff -u -3 -p -r1.26 pixmaploader.cpp
--- pixmaploader.cpp	2002/06/04 03:42:18	1.26
+++ pixmaploader.cpp	2002/06/12 09:24:22
@@ -57,6 +57,36 @@ void PixmapLoader::clear()
 	QPixmapCache::clear();
 }
 
+QColor colorize(const QColor& color, const QColor &col)
+{
+    int rval, gval, bval, val, alpha;
+    float rcol = col.red(), gcol = col.green(), bcol = col.blue();
+
+        val = qGray(color.rgb());
+        if (val < 128)
+        {
+             rval = static_cast<int>(rcol/128*val);
+             gval = static_cast<int>(gcol/128*val);
+             bval = static_cast<int>(bcol/128*val);
+        }
+        else if (val > 128)
+        {
+             rval = static_cast<int>((val-128)*(2-rcol/128)+rcol-1);
+             gval = static_cast<int>((val-128)*(2-gcol/128)+gcol-1);
+             bval = static_cast<int>((val-128)*(2-bcol/128)+bcol-1);
+        }
+	else // val == 128
+	{
+             rval = static_cast<int>(rcol);
+             gval = static_cast<int>(gcol);
+             bval = static_cast<int>(bcol);
+	}
+
+	alpha = qAlpha(color.rgb());
+    
+    return qRgba(rval, gval, bval, alpha);
+}
+
 QImage* PixmapLoader::getColored(int name, const QColor& color)
 {
 	KeramikEmbedImage* edata = KeramikGetDbImage(name);
@@ -84,9 +114,11 @@ QImage* PixmapLoader::getColored(int nam
 		Q_UINT32 alpha = edata->data[pos+3];
 		
 		QColor c( red, green, blue );
-		int h, s, v;
+		int h, s, v, s2, v2;
 		c.hsv( &h, &s, &v );
-		if ( hue >= 0 && h >= 0 ) h = ( h + 144 + hue ) % 360;
+		c = colorize(c,color);
+		c.hsv( &h, &s2, &v2 );
+//		if ( hue >= 0 && h >= 0 ) h = ( h + 144 + hue ) % 360;
 		if ( s ) s += sat / 2;
 		c.setHsv( h, QMIN( s, 255 ), QMIN( v * val / 228, 255 ) );
 		*write = qRgba( c.red(), c.green(), c.blue(), alpha );
@@ -127,9 +159,11 @@ QImage* PixmapLoader::getDisabled(int na
 		Q_UINT32 alpha = edata->data[pos+3];
 		
 		QColor c( red, green, blue );
-		int h, s, v;
+		int h, s, v, s2, v2;
 		c.hsv( &h, &s, &v );
-		if ( hue >= 0 && h >= 0 ) h = ( h + 144 + hue ) % 360;
+		c = colorize(c,color);
+		c.hsv( &h, &s2, &v2 );
+//		if ( hue >= 0 && h >= 0 ) h = ( h + 144 + hue ) % 360;
 		if ( s ) s += sat / 5;
 		c.setHsv( h, QMIN( s, 255 ), QMIN( v * val / 255, 255 ) );
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic