diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-12-07 14:37:12 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-08-11 14:12:48 +0000 |
commit | 9c9f98f2ff255da3e9a3ccdb81a82c53a105c8f9 (patch) | |
tree | 2f352bdf94b81d24271b7ce9e2bab3174ad0dff7 /tests/auto/gui/image/qimage/tst_qimage.cpp | |
parent | 1c623bc6d1c0a7ca52d81ca72c64f36898b3e12c (diff) |
Implement support for 16bpc image formats
Adds support for 16bit per color image formats in QImage. This makes it
possible to read and write 16bpc PNGs, and take full advantage of the
16bpc paint engine.
[ChangeLog][QtGui][QImage] QImage now supports 64bit image formats with
16 bits per color channel, compatible with 16bpc PNG or RGBA16 OpenGL
formats.
Task-number: QTBUG-45858
Change-Id: Icd28bd5868a6efcf65cb5bd56031d42941e04099
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto/gui/image/qimage/tst_qimage.cpp')
-rw-r--r-- | tests/auto/gui/image/qimage/tst_qimage.cpp | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index d32913b822..08aa00df56 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -291,6 +291,12 @@ static QLatin1String formatToString(QImage::Format format) return QLatin1String("Alpha8"); case QImage::Format_Grayscale8: return QLatin1String("Grayscale8"); + case QImage::Format_RGBX64: + return QLatin1String("RGBx64"); + case QImage::Format_RGBA64: + return QLatin1String("RGBA64"); + case QImage::Format_RGBA64_Premultiplied: + return QLatin1String("RGBA64pm"); default: break; }; @@ -2347,7 +2353,9 @@ void tst_QImage::rgbSwapped_data() { QTest::addColumn<QImage::Format>("format"); - for (int i = QImage::Format_Indexed8; i < QImage::Format_Alpha8; ++i) { + for (int i = QImage::Format_Indexed8; i < QImage::NImageFormats; ++i) { + if (i == QImage::Format_Alpha8 || i == QImage::Format_Grayscale8) + continue; QTest::addRow("%s", formatToString(QImage::Format(i)).data()) << QImage::Format(i); } } @@ -2515,14 +2523,7 @@ void tst_QImage::mirrored() void tst_QImage::inplaceRgbSwapped_data() { - QTest::addColumn<QImage::Format>("format"); - - QTest::newRow("Format_ARGB32_Premultiplied") << QImage::Format_ARGB32_Premultiplied; - QTest::newRow("Format_RGBA8888") << QImage::Format_RGBA8888; - QTest::newRow("Format_A2RGB30_Premultiplied") << QImage::Format_A2RGB30_Premultiplied; - QTest::newRow("Format_RGB888") << QImage::Format_RGB888; - QTest::newRow("Format_RGB16") << QImage::Format_RGB16; - QTest::newRow("Format_Indexed8") << QImage::Format_Indexed8; + rgbSwapped_data(); } void tst_QImage::inplaceRgbSwapped() @@ -2553,9 +2554,9 @@ void tst_QImage::inplaceRgbSwapped() for (int i = 0; i < imageSwapped.width(); ++i) { QRgb referenceColor = testColor[i]; QRgb swappedColor = imageSwapped.pixel(i, 0); - QCOMPARE(qRed(swappedColor) & 0xf8, qBlue(referenceColor) & 0xf8); - QCOMPARE(qGreen(swappedColor) & 0xf8, qGreen(referenceColor) & 0xf8); - QCOMPARE(qBlue(swappedColor) & 0xf8, qRed(referenceColor) & 0xf8); + QCOMPARE(qRed(swappedColor) & 0xf0, qBlue(referenceColor) & 0xf0); + QCOMPARE(qGreen(swappedColor) & 0xf0, qGreen(referenceColor) & 0xf0); + QCOMPARE(qBlue(swappedColor) & 0xf0, qRed(referenceColor) & 0xf0); } QCOMPARE(imageSwapped.constScanLine(0), orginalPtr); @@ -2771,9 +2772,13 @@ void tst_QImage::genericRgbConversion_data() QTest::addColumn<QImage::Format>("format"); QTest::addColumn<QImage::Format>("dest_format"); - for (int i = QImage::Format_RGB32; i < QImage::Format_Alpha8; ++i) { + for (int i = QImage::Format_RGB32; i < QImage::NImageFormats; ++i) { + if (i == QImage::Format_Alpha8 || i == QImage::Format_Grayscale8) + continue; const QLatin1String formatI = formatToString(QImage::Format(i)); - for (int j = QImage::Format_RGB32; j < QImage::Format_Alpha8; ++j) { + for (int j = QImage::Format_RGB32; j < QImage::NImageFormats; ++j) { + if (j == QImage::Format_Alpha8 || j == QImage::Format_Grayscale8) + continue; if (i == j) continue; QTest::addRow("%s -> %s", formatI.data(), formatToString(QImage::Format(j)).data()) @@ -2810,8 +2815,12 @@ void tst_QImage::inplaceRgbConversion_data() QTest::addColumn<QImage::Format>("format"); QTest::addColumn<QImage::Format>("dest_format"); - for (int i = QImage::Format_RGB32; i < QImage::Format_Alpha8; ++i) { - for (int j = QImage::Format_RGB32; j < QImage::Format_Alpha8; ++j) { + for (int i = QImage::Format_RGB32; i < QImage::NImageFormats; ++i) { + if (i == QImage::Format_Alpha8 || i == QImage::Format_Grayscale8) + continue; + for (int j = QImage::Format_RGB32; j < QImage::NImageFormats; ++j) { + if (j == QImage::Format_Alpha8 || j == QImage::Format_Grayscale8) + continue; if (i == j) continue; QTest::addRow("%s -> %s", formatToString(QImage::Format(i)).data(), formatToString(QImage::Format(j)).data()) @@ -2844,10 +2853,10 @@ void tst_QImage::inplaceRgbConversion() QCOMPARE(qGreen(convertedColor) & 0xF0, i * 16); } } - if (image.depth() == imageConverted.depth()) + if (qt_depthForFormat(format) == qt_depthForFormat(dest_format)) QCOMPARE(imageConverted.constScanLine(0), originalPtr); - { + if (qt_depthForFormat(format) <= 32) { // Test attempted inplace conversion of images created on existing buffer static const quint32 readOnlyData[] = { 0xff0102ffU, 0xff0506ffU, 0xff0910ffU, 0xff1314ffU }; quint32 readWriteData[] = { 0xff0102ffU, 0xff0506ffU, 0xff0910ffU, 0xff1314ffU }; @@ -2980,7 +2989,9 @@ void tst_QImage::invertPixelsRGB_data() { QTest::addColumn<QImage::Format>("image_format"); - for (int i = QImage::Format_RGB32; i < QImage::Format_Alpha8; ++i) { + for (int i = QImage::Format_RGB32; i < QImage::NImageFormats; ++i) { + if (i == QImage::Format_Alpha8 || i == QImage::Format_Grayscale8) + continue; QTest::addRow("%s", formatToString(QImage::Format(i)).data()) << QImage::Format(i); } } |