diff options
author | Gunnar Sletta <gunnar@trolltech.com> | 2009-08-31 05:19:23 (GMT) |
---|---|---|
committer | Gunnar Sletta <gunnar@trolltech.com> | 2009-08-31 11:07:58 (GMT) |
commit | b0295e82d08605a5a40803895544e57eeb6c8dc3 (patch) | |
tree | 8b21d5d7a5767375822a3e1bac30376b71facb70 /tests | |
parent | 6cf224de00ebf0681cd32a34866bdc3d16e0f45d (diff) | |
download | Qt-b0295e82d08605a5a40803895544e57eeb6c8dc3.zip Qt-b0295e82d08605a5a40803895544e57eeb6c8dc3.tar.gz Qt-b0295e82d08605a5a40803895544e57eeb6c8dc3.tar.bz2 |
Don't crash when convert Indexed8 without colortable to QPixmap
This implicitly adds "grayscale" support for indexed 8, but
only for the conversion. The alternative would be leave the pixels
uninitialized which would be less nice...
Reviewed-by: Samuel
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qpixmap/tst_qpixmap.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 8dd5f5f..9422327 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -83,6 +83,9 @@ private slots: void fromImage_data(); void fromImage(); + void fromUninitializedImage_data(); + void fromUninitializedImage(); + void convertFromImage_data(); void convertFromImage(); @@ -266,6 +269,32 @@ void tst_QPixmap::fromImage() QCOMPARE(result, image); } + +void tst_QPixmap::fromUninitializedImage_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; +} + +void tst_QPixmap::fromUninitializedImage() +{ + QFETCH(QImage::Format, format); + + QImage image(100, 100, format); + QPixmap pix = QPixmap::fromImage(image); + + // it simply shouldn't crash... + QVERIFY(true); + +} + void tst_QPixmap::convertFromImage_data() { QTest::addColumn<QImage>("img1"); |