[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: KIconLoader / QImage crash
From: Dirk Mueller <mueller () kde ! org>
Date: 2000-09-30 13:17:57
[Download RAW message or body]
On Sam, 30 Sep 2000, Dirk Mueller wrote:
> > comments?
> forgot to append the corrected patch..
argh. this time its the correct one, I promise :-)
/me needs something to eat..
Dirk
["patch.kiconeffect" (text/plain)]
Index: kiconeffect.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/kiconeffect.cpp,v
retrieving revision 1.23
diff -u -2 -d -p -t -B -b -r1.23 kiconeffect.cpp
--- kiconeffect.cpp 2000/09/29 18:20:42 1.23
+++ kiconeffect.cpp 2000/09/30 13:17:01
@@ -15,4 +15,5 @@
#include <unistd.h>
#include <math.h>
+#include <assert.h>
#include <qstring.h>
@@ -335,8 +336,7 @@ void KIconEffect::semiTransparent(QImage
{
// Insert transparent pixel into the clut.
- int transColor = 256;
- if (img.numColors() > 255)
- {
- // no space for transparent pixel..
+ int transColor = -1;
+
+ // search for a color that is already transparent
for (x=0; x<img.numColors(); x++)
{
@@ -348,10 +348,13 @@ void KIconEffect::semiTransparent(QImage
}
}
- } else
- {
- transColor = img.numColors()-1;
- }
+
+
+ // image must have transparency
+ assert(transColor >= 0 && transColor < img.numColors());
+
img.setColor(transColor, 0);
+ if(img.depth() == 8)
+ {
for (y=0; y<img.height(); y++)
{
@@ -361,4 +364,12 @@ void KIconEffect::semiTransparent(QImage
}
}
+ else
+ {
+ // SLOOW
+ for (y=0; y<img.height(); y++)
+ for (x=(y%2); x<img.width(); x+=2)
+ img.setPixel(x, y, transColor);
+ }
+ }
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic