From 36e6376755ce0f5dcd022e11d2539f125980a96b Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 3 Jul 2013 15:13:55 +0200 Subject: Support RGBA image format Support the byte-ordered RGBA format which is used by OpenGL, and many endian neutral byte formats. Task-number: QTBUG-32201 Change-Id: I77cffb4c30c69545fa96ded2f537b2ebd9351acb Reviewed-by: Allan Sandfeld Jensen --- tests/auto/gui/image/qimage/tst_qimage.cpp | 49 +++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'tests/auto/gui/image/qimage/tst_qimage.cpp') diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 2cd5216c59..7fdb2f4cba 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -728,6 +728,24 @@ void tst_QImage::convertToFormat_data() << int(QImage::Format_RGB888) << 0xffffffffu; QTest::newRow("semiblack pm -> rgb888") << int(QImage::Format_ARGB32_Premultiplied) << 0x7f000000u << int(QImage::Format_RGB888) << 0xff000000u; + + QTest::newRow("red rgba8888 -> argb32") << int(QImage::Format_RGBA8888) << 0xffff0000 + << int(QImage::Format_ARGB32) << 0xffff0000; + QTest::newRow("green rgba8888 -> argb32") << int(QImage::Format_RGBA8888) << 0xff00ff00 + << int(QImage::Format_ARGB32) << 0xff00ff00; + QTest::newRow("blue rgba8888 -> argb32") << int(QImage::Format_RGBA8888) << 0xff0000ff + << int(QImage::Format_ARGB32) << 0xff0000ff; + + QTest::newRow("semired rgba8888 -> argb pm") << int(QImage::Format_RGBA8888) << 0x7fff0000u + << int(QImage::Format_ARGB32_Premultiplied) << 0x7f7f0000u; + QTest::newRow("semigreen rgba8888 -> argb pm") << int(QImage::Format_RGBA8888) << 0x7f00ff00u + << int(QImage::Format_ARGB32_Premultiplied) << 0x7f007f00u; + QTest::newRow("semiblue rgba8888 -> argb pm") << int(QImage::Format_RGBA8888) << 0x7f0000ffu + << int(QImage::Format_ARGB32_Premultiplied) << 0x7f00007fu; + QTest::newRow("semiwhite rgba8888 -> argb pm") << int(QImage::Format_RGBA8888) << 0x7fffffffu + << int(QImage::Format_ARGB32_Premultiplied) << 0x7f7f7f7fu; + QTest::newRow("semiblack rgba8888 -> argb pm") << int(QImage::Format_RGBA8888) << 0x7f000000u + << int(QImage::Format_ARGB32_Premultiplied) << 0x7f000000u; } @@ -953,6 +971,10 @@ void tst_QImage::rotate_data() << QImage::Format_RGB888 << d; QTest::newRow(qPrintable(title.arg("Format_Indexed8"))) << QImage::Format_Indexed8 << d; + QTest::newRow(qPrintable(title.arg("Format_RGBX8888"))) + << QImage::Format_RGBX8888 << d; + QTest::newRow(qPrintable(title.arg("Format_RGBA8888_Premultiplied"))) + << QImage::Format_RGBA8888_Premultiplied << d; } } @@ -1161,6 +1183,21 @@ void tst_QImage::setPixel_data() << 0xff00ff00 << 0x00ff00u; QTest::newRow("RGB888 blue") << int(QImage::Format_RGB888) << 0xff0000ff << 0x0000ffu; +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + QTest::newRow("RGBA8888 red") << int(QImage::Format_RGBA8888) + << 0xffff0000u << 0xff0000ffu; + QTest::newRow("RGBA8888 green") << int(QImage::Format_RGBA8888) + << 0xff00ff00u << 0x00ff00ffu; + QTest::newRow("RGBA8888 blue") << int(QImage::Format_RGBA8888) + << 0xff0000ffu << 0x0000ffffu; +#else + QTest::newRow("RGBA8888 red") << int(QImage::Format_RGBA8888) + << 0xffff0000u << 0xff0000ffu; + QTest::newRow("RGBA8888 green") << int(QImage::Format_RGBA8888) + << 0xff00ff00u << 0xff00ff00u; + QTest::newRow("RGBA8888 blue") << int(QImage::Format_RGBA8888) + << 0xff0000ffu << 0xffff0000u; +#endif } void tst_QImage::setPixel() @@ -1184,6 +1221,9 @@ void tst_QImage::setPixel() case int(QImage::Format_RGB32): case int(QImage::Format_ARGB32): case int(QImage::Format_ARGB32_Premultiplied): + case int(QImage::Format_RGBX8888): + case int(QImage::Format_RGBA8888): + case int(QImage::Format_RGBA8888_Premultiplied): { for (int y = 0; y < h; ++y) { const quint32 *row = (const quint32*)(img.scanLine(y)); @@ -1901,6 +1941,8 @@ void tst_QImage::fillColor_data() "RGB888", "RGB444", "ARGB4444pm", + "RGBx8888", + "RGBA8888pm", 0 }; @@ -1917,7 +1959,9 @@ void tst_QImage::fillColor_data() QImage::Format_ARGB8555_Premultiplied, QImage::Format_RGB888, QImage::Format_RGB444, - QImage::Format_ARGB4444_Premultiplied + QImage::Format_ARGB4444_Premultiplied, + QImage::Format_RGBX8888, + QImage::Format_RGBA8888_Premultiplied, }; for (int i=0; names[i] != 0; ++i) { @@ -1935,6 +1979,7 @@ void tst_QImage::fillColor_data() QTest::newRow("RGB32, transparent") << QImage::Format_RGB32 << Qt::transparent << 0xff000000; QTest::newRow("ARGB32, transparent") << QImage::Format_ARGB32 << Qt::transparent << 0x00000000u; QTest::newRow("ARGB32pm, transparent") << QImage::Format_ARGB32_Premultiplied << Qt::transparent << 0x00000000u; + QTest::newRow("RGBA8888pm, transparent") << QImage::Format_RGBA8888_Premultiplied << Qt::transparent << 0x00000000u; } void tst_QImage::fillColor() @@ -2013,6 +2058,8 @@ void tst_QImage::rgbSwapped_data() QTest::newRow("Format_ARGB8555_Premultiplied") << QImage::Format_ARGB8555_Premultiplied; QTest::newRow("Format_RGB888") << QImage::Format_RGB888; QTest::newRow("Format_RGB444") << QImage::Format_RGB444; + QTest::newRow("Format_RGBX8888") << QImage::Format_RGBX8888; + QTest::newRow("Format_RGBA8888_Premultiplied") << QImage::Format_RGBA8888_Premultiplied; } void tst_QImage::rgbSwapped() -- cgit v1.2.3