diff options
author | Samuel Rødal <sroedal@trolltech.com> | 2009-11-06 15:09:16 (GMT) |
---|---|---|
committer | Samuel Rødal <sroedal@trolltech.com> | 2009-11-09 09:41:06 (GMT) |
commit | 845c69b2e780e1646f68ee99beda10768a1971e2 (patch) | |
tree | bdc68d5f18d3c3cba755722d55fb8c1851775273 /tests/auto/qimagewriter | |
parent | 3143014a80d1dfdfe3bb0f6175a3f7f7f41b2aaf (diff) | |
download | Qt-845c69b2e780e1646f68ee99beda10768a1971e2.zip Qt-845c69b2e780e1646f68ee99beda10768a1971e2.tar.gz Qt-845c69b2e780e1646f68ee99beda10768a1971e2.tar.bz2 |
Fixed loading of 8-bit grayscale TIFF files.
The PHOTOMETRIC_MINISBLACK and PHOTOMETRIC_MINISWHITE settings also
apply to 8-bit grayscale, so we need to check the bit depth of the image
as well. For convenience we also try to write the images using
PHOTOMETRIC_MINISBLACK and PHOTOMETRIC_MINISWHITE as opposed to
PHOTOMETRIC_PALETTE when we detect that the color table is grayscale.
Task-number: QTBUG-5459
Reviewed-by: Benjamin Poulain
Diffstat (limited to 'tests/auto/qimagewriter')
-rw-r--r-- | tests/auto/qimagewriter/tst_qimagewriter.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/tests/auto/qimagewriter/tst_qimagewriter.cpp b/tests/auto/qimagewriter/tst_qimagewriter.cpp index 584a060..5ec287d3 100644 --- a/tests/auto/qimagewriter/tst_qimagewriter.cpp +++ b/tests/auto/qimagewriter/tst_qimagewriter.cpp @@ -391,16 +391,27 @@ void tst_QImageWriter::readWriteNonDestructive_data() { QTest::addColumn<QImage::Format>("format"); QTest::addColumn<QImage::Format>("expectedFormat"); - QTest::newRow("tiff mono") << QImage::Format_Mono << QImage::Format_Mono; - QTest::newRow("tiff indexed") << QImage::Format_Indexed8 << QImage::Format_Indexed8; - QTest::newRow("tiff rgb32") << QImage::Format_ARGB32 << QImage::Format_ARGB32; + QTest::addColumn<bool>("grayscale"); + QTest::newRow("tiff mono") << QImage::Format_Mono << QImage::Format_Mono << false; + QTest::newRow("tiff indexed") << QImage::Format_Indexed8 << QImage::Format_Indexed8 << false; + QTest::newRow("tiff rgb32") << QImage::Format_ARGB32 << QImage::Format_ARGB32 << false; + QTest::newRow("tiff grayscale") << QImage::Format_Indexed8 << QImage::Format_Indexed8 << true; } void tst_QImageWriter::readWriteNonDestructive() { QFETCH(QImage::Format, format); QFETCH(QImage::Format, expectedFormat); + QFETCH(bool, grayscale); QImage image = QImage(prefix + "colorful.bmp").convertToFormat(format); + + if (grayscale) { + QVector<QRgb> colors; + for (int i = 0; i < 256; ++i) + colors << qRgb(i, i, i); + image.setColorTable(colors); + } + QVERIFY(image.save(prefix + "gen-readWriteNonDestructive.tiff")); QImage image2 = QImage(prefix + "gen-readWriteNonDestructive.tiff"); |