From 1d4f24820c0fff474d524e006d715e13e409a4b8 Mon Sep 17 00:00:00 2001 From: Dayang Shen Date: Sat, 5 Mar 2016 15:40:30 +0800 Subject: Add animation support to WebP plugin We now use WebP Demux API to decode both single image format and muxed animation format. Change-Id: Ia2922892a3a626e9921c3910801d7c975d9fc6a2 Reviewed-by: aavit Reviewed-by: Liang Qi --- tests/auto/webp/images/kollada_animation.webp | Bin 0 -> 24726 bytes tests/auto/webp/tst_qwebp.cpp | 60 ++++++++++++++++++++++++++ tests/auto/webp/webp.qrc | 1 + 3 files changed, 61 insertions(+) create mode 100644 tests/auto/webp/images/kollada_animation.webp (limited to 'tests') diff --git a/tests/auto/webp/images/kollada_animation.webp b/tests/auto/webp/images/kollada_animation.webp new file mode 100644 index 0000000..c38751a Binary files /dev/null and b/tests/auto/webp/images/kollada_animation.webp differ diff --git a/tests/auto/webp/tst_qwebp.cpp b/tests/auto/webp/tst_qwebp.cpp index 4126076..d1d30db 100644 --- a/tests/auto/webp/tst_qwebp.cpp +++ b/tests/auto/webp/tst_qwebp.cpp @@ -37,6 +37,8 @@ private slots: void initTestCase(); void readImage_data(); void readImage(); + void readAnimation_data(); + void readAnimation(); void writeImage_data(); void writeImage(); }; @@ -69,6 +71,64 @@ void tst_qwebp::readImage() QCOMPARE(image.size(), size); } +void tst_qwebp::readAnimation_data() +{ + QTest::addColumn("fileName"); + QTest::addColumn("size"); + QTest::addColumn("imageCount"); + QTest::addColumn("loopCount"); + QTest::addColumn("bgColor"); + QTest::addColumn >("imageRects"); + QTest::addColumn >("imageDelays"); + + QTest::newRow("kollada") + << QString("kollada") + << QSize(436, 160) + << 1 + << 0 + << QColor() + << (QList() << QRect(0, 0, 436, 160)) + << (QList() << 0); + QTest::newRow("kollada_animation") + << QString("kollada_animation") + << QSize(536, 260) + << 2 + << 2 + << QColor(128, 128, 128, 128) + << (QList() << QRect(0, 0, 436, 160) << QRect(100, 100, 436, 160)) + << (QList() << 1000 << 1200); +} + +void tst_qwebp::readAnimation() +{ + QFETCH(QString, fileName); + QFETCH(QSize, size); + QFETCH(int, imageCount); + QFETCH(int, loopCount); + QFETCH(QColor, bgColor); + QFETCH(QList, imageRects); + QFETCH(QList, imageDelays); + + const QString path = QStringLiteral(":/images/") + fileName + QStringLiteral(".webp"); + QImageReader reader(path); + QVERIFY(reader.canRead()); + QCOMPARE(reader.size(), size); + QCOMPARE(reader.imageCount(), imageCount); + QCOMPARE(reader.loopCount(), loopCount); + QCOMPARE(reader.backgroundColor(), bgColor); + + for (int i = 0; i < reader.imageCount(); ++i) { + QImage image = reader.read(); + QVERIFY2(!image.isNull(), qPrintable(reader.errorString())); + QCOMPARE(image.size(), size); + QCOMPARE(reader.currentImageNumber(), i); + QCOMPARE(reader.currentImageRect(), imageRects[i]); + QCOMPARE(reader.nextImageDelay(), imageDelays[i]); + } + + QVERIFY(reader.read().isNull()); +} + void tst_qwebp::writeImage_data() { QTest::addColumn("fileName"); diff --git a/tests/auto/webp/webp.qrc b/tests/auto/webp/webp.qrc index ab0b1b2..6519e58 100644 --- a/tests/auto/webp/webp.qrc +++ b/tests/auto/webp/webp.qrc @@ -3,5 +3,6 @@ images/kollada.png images/kollada.webp images/kollada_lossless.webp + images/kollada_animation.webp -- cgit v1.2.1