summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@nokia.com>2009-07-22 10:55:25 (GMT)
committerPierre Rossi <pierre.rossi@nokia.com>2009-09-02 11:51:20 (GMT)
commit7d1a19669b8828803d7393396b1f109d86009d3b (patch)
tree9634e5cd02df6ce619428607a69ec641913ea05c
parent294bcb9ecb43742bdca5a9ffd7d26ce21e971126 (diff)
downloadQt-7d1a19669b8828803d7393396b1f109d86009d3b.zip
Qt-7d1a19669b8828803d7393396b1f109d86009d3b.tar.gz
Qt-7d1a19669b8828803d7393396b1f109d86009d3b.tar.bz2
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
-rw-r--r--src/plugins/imageformats/gif/qgifhandler.cpp4
-rw-r--r--tests/auto/qimagereader/images/qt.gifbin0 -> 26504 bytes
-rw-r--r--tests/auto/qimagereader/images/qt1.gifbin0 -> 7216 bytes
-rw-r--r--tests/auto/qimagereader/images/qt2.gifbin0 -> 5559 bytes
-rw-r--r--tests/auto/qimagereader/images/qt3.gifbin0 -> 4702 bytes
-rw-r--r--tests/auto/qimagereader/images/qt4.gifbin0 -> 4310 bytes
-rw-r--r--tests/auto/qimagereader/images/qt5.gifbin0 -> 4234 bytes
-rw-r--r--tests/auto/qimagereader/images/qt6.gifbin0 -> 4732 bytes
-rw-r--r--tests/auto/qimagereader/images/qt7.gifbin0 -> 5265 bytes
-rw-r--r--tests/auto/qimagereader/images/qt8.gifbin0 -> 6144 bytes
-rw-r--r--tests/auto/qimagereader/qimagereader.qrc13
-rw-r--r--tests/auto/qimagereader/tst_qimagereader.cpp13
12 files changed, 26 insertions, 4 deletions
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
--- /dev/null
+++ b/tests/auto/qimagereader/images/qt.gif
Binary files differ
diff --git a/tests/auto/qimagereader/images/qt1.gif b/tests/auto/qimagereader/images/qt1.gif
new file mode 100644
index 0000000..0ce910c
--- /dev/null
+++ b/tests/auto/qimagereader/images/qt1.gif
Binary files differ
diff --git a/tests/auto/qimagereader/images/qt2.gif b/tests/auto/qimagereader/images/qt2.gif
new file mode 100644
index 0000000..993a315
--- /dev/null
+++ b/tests/auto/qimagereader/images/qt2.gif
Binary files differ
diff --git a/tests/auto/qimagereader/images/qt3.gif b/tests/auto/qimagereader/images/qt3.gif
new file mode 100644
index 0000000..7391678
--- /dev/null
+++ b/tests/auto/qimagereader/images/qt3.gif
Binary files differ
diff --git a/tests/auto/qimagereader/images/qt4.gif b/tests/auto/qimagereader/images/qt4.gif
new file mode 100644
index 0000000..41109a9
--- /dev/null
+++ b/tests/auto/qimagereader/images/qt4.gif
Binary files differ
diff --git a/tests/auto/qimagereader/images/qt5.gif b/tests/auto/qimagereader/images/qt5.gif
new file mode 100644
index 0000000..5a3fb54
--- /dev/null
+++ b/tests/auto/qimagereader/images/qt5.gif
Binary files differ
diff --git a/tests/auto/qimagereader/images/qt6.gif b/tests/auto/qimagereader/images/qt6.gif
new file mode 100644
index 0000000..f22e7c9
--- /dev/null
+++ b/tests/auto/qimagereader/images/qt6.gif
Binary files differ
diff --git a/tests/auto/qimagereader/images/qt7.gif b/tests/auto/qimagereader/images/qt7.gif
new file mode 100644
index 0000000..a315671
--- /dev/null
+++ b/tests/auto/qimagereader/images/qt7.gif
Binary files differ
diff --git a/tests/auto/qimagereader/images/qt8.gif b/tests/auto/qimagereader/images/qt8.gif
new file mode 100644
index 0000000..2a7d09e
--- /dev/null
+++ b/tests/auto/qimagereader/images/qt8.gif
Binary files differ
diff --git a/tests/auto/qimagereader/qimagereader.qrc b/tests/auto/qimagereader/qimagereader.qrc
index 13ce582..e3113c6 100644
--- a/tests/auto/qimagereader/qimagereader.qrc
+++ b/tests/auto/qimagereader/qimagereader.qrc
@@ -1,5 +1,5 @@
-<!DOCTYPE RCC><RCC version="1.0">
- <qresource>
+<RCC>
+ <qresource prefix="/" >
<file>images/16bpp.bmp</file>
<file>images/4bpp-rle.bmp</file>
<file>images/YCbCr_cmyk.jpg</file>
@@ -47,5 +47,14 @@
<file>images/tst7.png</file>
<file>images/transparent.xpm</file>
<file>images/trolltech.gif</file>
+ <file>images/qt.gif</file>
+ <file>images/qt1.gif</file>
+ <file>images/qt2.gif</file>
+ <file>images/qt3.gif</file>
+ <file>images/qt4.gif</file>
+ <file>images/qt5.gif</file>
+ <file>images/qt6.gif</file>
+ <file>images/qt7.gif</file>
+ <file>images/qt8.gif</file>
</qresource>
</RCC>
diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp
index 18900b4..1403280 100644
--- a/tests/auto/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/qimagereader/tst_qimagereader.cpp
@@ -136,6 +136,7 @@ private slots:
#if defined QTEST_HAVE_GIF
void gifHandlerBugs();
+ void animatedGif();
#endif
void readCorruptImage_data();
@@ -671,6 +672,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