summaryrefslogtreecommitdiffstats
path: root/tests/auto/qimagereader
diff options
context:
space:
mode:
authoraavit <qt-info@nokia.com>2010-09-24 17:51:14 +0200
committeraavit <qt-info@nokia.com>2010-09-27 12:15:24 +0200
commitc9a5ab5fd506663c5a7cd587d1b963c067d334bf (patch)
tree5484265914a84526aab7c1bf5723b03c8000bd6c /tests/auto/qimagereader
parentd5e6aa0a70004338a644387ba3d682a73fa169a9 (diff)
Avoid creating copy of an image in memory when storing as png
Task-number: QT-3871 Reviewed-by: Kim
Diffstat (limited to 'tests/auto/qimagereader')
-rw-r--r--tests/auto/qimagereader/tst_qimagereader.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp
index 3bee5d98aa..4b4bdd6a3b 100644
--- a/tests/auto/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/qimagereader/tst_qimagereader.cpp
@@ -178,6 +178,8 @@ private slots:
void testIgnoresFormatAndExtension_data();
void testIgnoresFormatAndExtension();
+ void saveFormat_data();
+ void saveFormat();
};
static const QLatin1String prefix(SRCDIR "/images/");
@@ -1905,5 +1907,46 @@ void tst_QImageReader::testIgnoresFormatAndExtension()
}
}
+
+void tst_QImageReader::saveFormat_data()
+{
+ QTest::addColumn<QImage::Format>("format");
+
+ QTest::newRow("Format_Mono") << QImage::Format_Mono;
+ QTest::newRow("Format_MonoLSB") << QImage::Format_MonoLSB;
+ QTest::newRow("Format_Indexed8") << QImage::Format_Indexed8;
+ QTest::newRow("Format_RGB32") << QImage::Format_RGB32;
+ QTest::newRow("Format_ARGB32") << QImage::Format_ARGB32;
+ QTest::newRow("Format_ARGB32_Premultiplied") << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("Format_RGB16") << QImage::Format_RGB16;
+ QTest::newRow("Format_ARGB8565_Premultiplied") << QImage::Format_ARGB8565_Premultiplied;
+ QTest::newRow("Format_RGB666") << QImage::Format_RGB666;
+ QTest::newRow("Format_ARGB6666_Premultiplied") << QImage::Format_ARGB6666_Premultiplied;
+ QTest::newRow("Format_RGB555") << QImage::Format_RGB555;
+ QTest::newRow("Format_ARGB8555_Premultiplied") << QImage::Format_ARGB8555_Premultiplied;
+ QTest::newRow("Format_RGB888") << QImage::Format_RGB888;
+ QTest::newRow("Format_RGB444") << QImage::Format_RGB444;
+ QTest::newRow("Format_ARGB4444_Premultiplied") << QImage::Format_ARGB4444_Premultiplied;
+}
+
+void tst_QImageReader::saveFormat()
+{
+ QFETCH(QImage::Format, format);
+
+ QImage orig(":/images/kollada.png");
+
+ QImage converted = orig.convertToFormat(format);
+ QBuffer buf;
+ buf.open(QIODevice::WriteOnly);
+ QVERIFY(converted.save(&buf, "png"));
+ buf.close();
+ QImage stored = QImage::fromData(buf.buffer(), "png");
+
+ stored = stored.convertToFormat(QImage::Format_ARGB32);
+ converted = converted.convertToFormat(QImage::Format_ARGB32);
+ QCOMPARE(stored, converted);
+}
+
+
QTEST_MAIN(tst_QImageReader)
#include "tst_qimagereader.moc"