summaryrefslogtreecommitdiffstats
path: root/tests/auto/qimage
diff options
context:
space:
mode:
authorBenjamin Poulain <benjamin.poulain@nokia.com>2009-05-27 11:23:53 (GMT)
committerBenjamin Poulain <benjamin.poulain@nokia.com>2009-05-27 11:30:06 (GMT)
commit71cb35e942b94e4dba2055acdebbf90c352da762 (patch)
tree9b1e845fc52698051badc263bb4cc01345c9f01f /tests/auto/qimage
parent73e7d0cbed0261715f534d95f81055bf97ce4314 (diff)
downloadQt-71cb35e942b94e4dba2055acdebbf90c352da762.zip
Qt-71cb35e942b94e4dba2055acdebbf90c352da762.tar.gz
Qt-71cb35e942b94e4dba2055acdebbf90c352da762.tar.bz2
Add comparation of images with indexed color
Previously, two images with indexed colors were not equal if their color tables were not the same. The image are not compared by the value of the pixels Reviewed-by: Samuel
Diffstat (limited to 'tests/auto/qimage')
-rw-r--r--tests/auto/qimage/tst_qimage.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp
index c6b0560..b7199f3 100644
--- a/tests/auto/qimage/tst_qimage.cpp
+++ b/tests/auto/qimage/tst_qimage.cpp
@@ -131,6 +131,8 @@ private slots:
void nullSize();
void premultipliedAlphaConsistency();
+
+ void compareIndexed();
};
tst_QImage::tst_QImage()
@@ -1762,5 +1764,31 @@ void tst_QImage::premultipliedAlphaConsistency()
}
}
+void tst_QImage::compareIndexed()
+{
+ QImage img(256, 1, QImage::Format_Indexed8);
+
+ QVector<QRgb> colorTable(256);
+ for (int i = 0; i < 256; ++i)
+ colorTable[i] = qRgb(i, i, i);
+ img.setColorTable(colorTable);
+
+ for (int i = 0; i < 256; ++i) {
+ img.setPixel(i, 0, i);
+ }
+
+ QImage imgInverted(256, 1, QImage::Format_Indexed8);
+ QVector<QRgb> invertedColorTable(256);
+ for (int i = 0; i < 256; ++i)
+ invertedColorTable[255-i] = qRgb(i, i, i);
+ imgInverted.setColorTable(invertedColorTable);
+
+ for (int i = 0; i < 256; ++i) {
+ imgInverted.setPixel(i, 0, (255-i));
+ }
+
+ QCOMPARE(img, imgInverted);
+}
+
QTEST_MAIN(tst_QImage)
#include "tst_qimage.moc"