summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/image/qgifhandler.cpp15
-rw-r--r--tests/auto/qimagereader/images/trans.gifbin0 -> 3234 bytes
-rw-r--r--tests/auto/qimagereader/tst_qimagereader.cpp9
3 files changed, 15 insertions, 9 deletions
diff --git a/src/gui/image/qgifhandler.cpp b/src/gui/image/qgifhandler.cpp
index cedb27c..b60d1a1 100644
--- a/src/gui/image/qgifhandler.cpp
+++ b/src/gui/image/qgifhandler.cpp
@@ -488,7 +488,7 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length,
} else {
if (needfirst) {
firstcode=oldcode=code;
- if (!out_of_bounds && image->height() > y && firstcode!=trans_index)
+ if (!out_of_bounds && image->height() > y && ((frame == 0) || (firstcode != trans_index)))
((QRgb*)FAST_SCAN_LINE(bits, bpl, y))[x] = color(firstcode);
x++;
if (x>=swidth) out_of_bounds = true;
@@ -540,17 +540,13 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length,
}
oldcode=incode;
const int h = image->height();
- const QRgb *map = lcmap ? localcmap : globalcmap;
QRgb *line = 0;
if (!out_of_bounds && h > y)
line = (QRgb*)FAST_SCAN_LINE(bits, bpl, y);
while (sp>stack) {
const uchar index = *(--sp);
- if (!out_of_bounds && h > y && index!=trans_index) {
- if (index > ncols)
- line[x] = Q_TRANSPARENT;
- else
- line[x] = map ? map[index] : 0;
+ if (!out_of_bounds && h > y && ((frame == 0) || (index != trans_index))) {
+ line[x] = color(index);
}
x++;
if (x>=swidth) out_of_bounds = true;
@@ -1031,11 +1027,12 @@ void QGIFFormat::nextY(unsigned char *bits, int bpl)
inline QRgb QGIFFormat::color(uchar index) const
{
- if (index == trans_index || index > ncols)
+ if (index > ncols)
return Q_TRANSPARENT;
QRgb *map = lcmap ? localcmap : globalcmap;
- return map ? map[index] : 0;
+ QRgb col = map ? map[index] : 0;
+ return index == trans_index ? col & Q_TRANSPARENT : col;
}
//-------------------------------------------------------------------------
diff --git a/tests/auto/qimagereader/images/trans.gif b/tests/auto/qimagereader/images/trans.gif
new file mode 100644
index 0000000..e26398a
--- /dev/null
+++ b/tests/auto/qimagereader/images/trans.gif
Binary files differ
diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp
index 7a2acee..14ce74b 100644
--- a/tests/auto/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/qimagereader/tst_qimagereader.cpp
@@ -855,6 +855,15 @@ void tst_QImageReader::gifHandlerBugs()
QVERIFY(io.canRead());
QCOMPARE(io.loopCount(), -1);
}
+
+ // Check that pixels with the transparent color are transparent but not zeroed
+ {
+ QImageReader io(prefix + "trans.gif");
+ QVERIFY(io.canRead());
+ QImage im = io.read();
+ QCOMPARE(im.pixel(0,0), qRgba(0x3f, 0xff, 0x7f, 0x00));
+ QCOMPARE(im.pixel(10,10), qRgba(0x3f, 0xff, 0x7f, 0x00));
+ }
}
void tst_QImageReader::animatedGif()