[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 11:29:53
[Download RAW message or body]
On Sam, 30 Sep 2000, Dirk Mueller wrote:
> if I comment out KIconEffect::semiTransparent, I have no crash.
> And I cannot see any libpng related function call in there.
ok, at a closer look to that function I saw that its COMPLETELY FSCKED UP!
the appended patch fixes the most common bugs in it, but there are still
several left..
makes KDE not crash on tackats icons.
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 -b -r1.23 kiconeffect.cpp
--- kiconeffect.cpp 2000/09/29 18:20:42 1.23
+++ kiconeffect.cpp 2000/09/30 11:29:46
@@ -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 if a color is already transparent
for (x=0; x<img.numColors(); x++)
{
@@ -348,15 +348,31 @@ void KIconEffect::semiTransparent(QImage
}
}
- } else
+
+ // if we still havn't found a transparent one
+ if(transColor < 0)
{
- transColor = img.numColors()-1;
+ if(img.depth() == 1)
+ {
+ // convert to 8 bit
+ img = img.convertDepth(8);
+ img.setNumColors(img.numColors() + 1);
+ transColor = img.numColors() - 1;
+ }
+ else
+ {
+ // its 8/16 bit, should become 32bit
+ // HACK: use the last color
+ transColor = img.numColors() - 1;
+ }
}
+
img.setColor(transColor, 0);
+ assert(transColor <= img.numColors());
for (y=0; y<img.height(); y++)
{
- unsigned char *line = img.scanLine(y);
+ // SLOOOOOW
for (x=(y%2); x<img.width(); x+=2)
- line[x] = transColor;
+ 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