From a7178d96d7e9c50a4392ab9ee23b219d26028ed3 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Wed, 22 Jul 2009 12:55:25 +0200 Subject: Fixes the gif plugin's rendering for some animated gif files. In the case of optimized animated gifs, we don't want to discard the contents of the previous frame, this is handled if needed in the disposal process. Task-number: 247365 Reviewed-by: Samuel --- src/plugins/imageformats/gif/qgifhandler.cpp | 4 ++-- tests/auto/qimagereader/images/qt.gif | Bin 0 -> 26504 bytes tests/auto/qimagereader/images/qt1.gif | Bin 0 -> 7216 bytes tests/auto/qimagereader/images/qt2.gif | Bin 0 -> 5559 bytes tests/auto/qimagereader/images/qt3.gif | Bin 0 -> 4702 bytes tests/auto/qimagereader/images/qt4.gif | Bin 0 -> 4310 bytes tests/auto/qimagereader/images/qt5.gif | Bin 0 -> 4234 bytes tests/auto/qimagereader/images/qt6.gif | Bin 0 -> 4732 bytes tests/auto/qimagereader/images/qt7.gif | Bin 0 -> 5265 bytes tests/auto/qimagereader/images/qt8.gif | Bin 0 -> 6144 bytes tests/auto/qimagereader/qimagereader.qrc | 13 +++++++++++-- tests/auto/qimagereader/tst_qimagereader.cpp | 13 +++++++++++++ 12 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 tests/auto/qimagereader/images/qt.gif create mode 100644 tests/auto/qimagereader/images/qt1.gif create mode 100644 tests/auto/qimagereader/images/qt2.gif create mode 100644 tests/auto/qimagereader/images/qt3.gif create mode 100644 tests/auto/qimagereader/images/qt4.gif create mode 100644 tests/auto/qimagereader/images/qt5.gif create mode 100644 tests/auto/qimagereader/images/qt6.gif create mode 100644 tests/auto/qimagereader/images/qt7.gif create mode 100644 tests/auto/qimagereader/images/qt8.gif diff --git a/src/plugins/imageformats/gif/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp index de985d8..0f6a349 100644 --- a/src/plugins/imageformats/gif/qgifhandler.cpp +++ b/src/plugins/imageformats/gif/qgifhandler.cpp @@ -234,7 +234,7 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, #define LM(l, m) (((m)<<8)|l) digress = false; - int initial = length; + const int initial = length; while (!digress && length) { length--; unsigned char ch=*buffer++; @@ -333,7 +333,7 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, sheight = newtop + newheight; QImage::Format format = trans_index >= 0 ? QImage::Format_ARGB32 : QImage::Format_RGB32; - if (image->isNull() || (image->size() != QSize(swidth, sheight)) || image->format() != format) { + if (image->isNull()) { (*image) = QImage(swidth, sheight, format); memset(image->bits(), 0, image->numBytes()); diff --git a/tests/auto/qimagereader/images/qt.gif b/tests/auto/qimagereader/images/qt.gif new file mode 100644 index 0000000..e0a5a80 Binary files /dev/null and b/tests/auto/qimagereader/images/qt.gif differ diff --git a/tests/auto/qimagereader/images/qt1.gif b/tests/auto/qimagereader/images/qt1.gif new file mode 100644 index 0000000..0ce910c Binary files /dev/null and b/tests/auto/qimagereader/images/qt1.gif differ diff --git a/tests/auto/qimagereader/images/qt2.gif b/tests/auto/qimagereader/images/qt2.gif new file mode 100644 index 0000000..993a315 Binary files /dev/null and b/tests/auto/qimagereader/images/qt2.gif differ diff --git a/tests/auto/qimagereader/images/qt3.gif b/tests/auto/qimagereader/images/qt3.gif new file mode 100644 index 0000000..7391678 Binary files /dev/null and b/tests/auto/qimagereader/images/qt3.gif differ diff --git a/tests/auto/qimagereader/images/qt4.gif b/tests/auto/qimagereader/images/qt4.gif new file mode 100644 index 0000000..41109a9 Binary files /dev/null and b/tests/auto/qimagereader/images/qt4.gif differ diff --git a/tests/auto/qimagereader/images/qt5.gif b/tests/auto/qimagereader/images/qt5.gif new file mode 100644 index 0000000..5a3fb54 Binary files /dev/null and b/tests/auto/qimagereader/images/qt5.gif differ diff --git a/tests/auto/qimagereader/images/qt6.gif b/tests/auto/qimagereader/images/qt6.gif new file mode 100644 index 0000000..f22e7c9 Binary files /dev/null and b/tests/auto/qimagereader/images/qt6.gif differ diff --git a/tests/auto/qimagereader/images/qt7.gif b/tests/auto/qimagereader/images/qt7.gif new file mode 100644 index 0000000..a315671 Binary files /dev/null and b/tests/auto/qimagereader/images/qt7.gif differ diff --git a/tests/auto/qimagereader/images/qt8.gif b/tests/auto/qimagereader/images/qt8.gif new file mode 100644 index 0000000..2a7d09e Binary files /dev/null and b/tests/auto/qimagereader/images/qt8.gif differ diff --git a/tests/auto/qimagereader/qimagereader.qrc b/tests/auto/qimagereader/qimagereader.qrc index c6b963b..11b9406 100644 --- a/tests/auto/qimagereader/qimagereader.qrc +++ b/tests/auto/qimagereader/qimagereader.qrc @@ -1,5 +1,5 @@ - - + + images/16bpp.bmp images/4bpp-rle.bmp images/YCbCr_cmyk.jpg @@ -48,5 +48,14 @@ images/tst7.png images/transparent.xpm images/trolltech.gif + images/qt.gif + images/qt1.gif + images/qt2.gif + images/qt3.gif + images/qt4.gif + images/qt5.gif + images/qt6.gif + images/qt7.gif + images/qt8.gif diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index 27c6925..a325a33 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -140,6 +140,7 @@ private slots: #if defined QTEST_HAVE_GIF void gifHandlerBugs(); + void animatedGif(); #endif void readCorruptImage_data(); @@ -710,6 +711,18 @@ void tst_QImageReader::gifHandlerBugs() QCOMPARE(im1.convertToFormat(QImage::Format_ARGB32), im2.convertToFormat(QImage::Format_ARGB32)); } } + +void tst_QImageReader::animatedGif() +{ + QImageReader io(prefix + "qt.gif"); + QImage image= io.read(); + int i=0; + while(!image.isNull()){ + QString frameName = QString(prefix + "qt%1.gif").arg(++i); + QCOMPARE(image, QImage(frameName)); + image=io.read(); + } +} #endif class Server : public QObject -- cgit v0.12