diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-07-01 09:59:28 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2015-07-01 09:59:28 +0000 |
commit | 0698f876ca02b85c1e584b72cac3444796f6a355 (patch) | |
tree | 022748fb34278fb455d8e029d912dfb0b545f443 /tests/auto/gui/image/qimage/tst_qimage.cpp | |
parent | cd297f99a2ce9c53c3ac4633bdf2425af364a1bc (diff) | |
parent | 0aa2d318b1524cdab42ab9988270779ddcc1922a (diff) |
Merge "Merge remote-tracking branch 'origin/5.5' into dev" into refs/staging/dev
Diffstat (limited to 'tests/auto/gui/image/qimage/tst_qimage.cpp')
-rw-r--r-- | tests/auto/gui/image/qimage/tst_qimage.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index da29a57f98..f7c71f05bd 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -190,6 +190,8 @@ private slots: void devicePixelRatio(); void rgb30Unpremul(); + void rgb30Repremul_data(); + void rgb30Repremul(); void metadataPassthrough(); @@ -2946,6 +2948,31 @@ void tst_QImage::rgb30Unpremul() QCOMPARE(bbits[2], (3U << 30) | (201 << 20) | (393 << 10) | 777); } +void tst_QImage::rgb30Repremul_data() +{ + QTest::addColumn<uint>("color"); + for (int i = 255; i > 0; i -= 15) { + QTest::newRow(qPrintable(QStringLiteral("100% red=") + QString::number(i))) << qRgba(i, 0, 0, 0xff); + QTest::newRow(qPrintable(QStringLiteral("75% red=") + QString::number(i))) << qRgba(i, 0, 0, 0xc0); + QTest::newRow(qPrintable(QStringLiteral("50% red=") + QString::number(i))) << qRgba(i, 0, 0, 0x80); + QTest::newRow(qPrintable(QStringLiteral("37.5% red=") + QString::number(i))) << qRgba(i, 0, 0, 0x60); + } +} + +void tst_QImage::rgb30Repremul() +{ + QFETCH(uint, color); + + QImage a(1, 1, QImage::Format_ARGB32); + a.setPixel(0, 0, color); + + QImage b = a.convertToFormat(QImage::Format_A2BGR30_Premultiplied); + b = b.convertToFormat(QImage::Format_ARGB32); + uint expectedColor = qUnpremultiply(qPremultiply(color)); + uint newColor = b.pixel(0, 0); + QVERIFY(qAbs(qRed(newColor) - qRed(expectedColor)) <= 1); +} + void tst_QImage::metadataPassthrough() { QImage a(64, 64, QImage::Format_ARGB32); |