And fix handling and test of QImage::fill(uint) as well
Only RGB444 and RGB666 were treated slighlty different from the rest, but the test had a few additional mistakes. Change-Id: I4728b4036affedfffce8bca5c1e7be3869344fbe Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit c2bec047e281d949015ecd27daf2ba2d51b21526) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
e8a2ca314b
commit
b74f77bd63
@ -1709,10 +1709,14 @@ void QImage::fill(uint pixel)
|
||||
w, d->height, d->bytes_per_line);
|
||||
return;
|
||||
} else if (d->depth == 16) {
|
||||
if (d->format == Format_RGB444)
|
||||
pixel |= 0xf000;
|
||||
qt_rectfill<quint16>(reinterpret_cast<quint16*>(d->data), pixel,
|
||||
0, 0, d->width, d->height, d->bytes_per_line);
|
||||
return;
|
||||
} else if (d->depth == 24) {
|
||||
if (d->format == Format_RGB666)
|
||||
pixel |= 0xfc0000;
|
||||
qt_rectfill<quint24>(reinterpret_cast<quint24*>(d->data), pixel,
|
||||
0, 0, d->width, d->height, d->bytes_per_line);
|
||||
return;
|
||||
|
@ -2406,10 +2406,13 @@ void tst_QImage::fillPixel_data()
|
||||
|
||||
QTest::newRow("RGB16, transparent") << QImage::Format_RGB16 << 0x0u << 0xff000000u;
|
||||
QTest::newRow("RGB32, transparent") << QImage::Format_RGB32 << 0x0u << 0xff000000u;
|
||||
QTest::newRow("RGB444, transparent") << QImage::Format_RGB444 << 0x0u << 0xff000000u;
|
||||
QTest::newRow("RGB666, transparent") << QImage::Format_RGB666 << 0x0u << 0xff000000u;
|
||||
QTest::newRow("RGBx8888, transparent") << QImage::Format_RGBX8888 << 0x0u << 0xff000000u;
|
||||
QTest::newRow("ARGB32, transparent") << QImage::Format_ARGB32 << 0x0u << 0x00000000u;
|
||||
QTest::newRow("ARGB32pm, transparent") << QImage::Format_ARGB32_Premultiplied << 0x0u << 0x00000000u;
|
||||
QTest::newRow("RGBA8888pm, transparent") << QImage::Format_RGBA8888_Premultiplied << 0x0u << 0x00000000u;
|
||||
QTest::newRow("Grayscale8, transparent") << QImage::Format_Grayscale8 << 0x0u << 0xff000000u;
|
||||
QTest::newRow("Alpha8, transparent") << QImage::Format_Alpha8 << 0x0u << 0x00000000u;
|
||||
|
||||
QTest::newRow("RGB16, red") << QImage::Format_RGB16 << (uint)qConvertRgb32To16(0xffff0000) << 0xffff0000u;
|
||||
@ -2417,13 +2420,14 @@ void tst_QImage::fillPixel_data()
|
||||
QTest::newRow("ARGB32, red") << QImage::Format_ARGB32 << 0xffff0000u << 0xffff0000u;
|
||||
QTest::newRow("RGBA8888, red") << QImage::Format_RGBA8888 << 0xff0000ffu << 0xffff0000u;
|
||||
|
||||
QTest::newRow("Grayscale8, grey") << QImage::Format_Grayscale8 << 0xff808080u << 0xff808080u;
|
||||
QTest::newRow("Grayscale8, grey") << QImage::Format_Grayscale8 << 0x80u << 0xff808080u;
|
||||
|
||||
QTest::newRow("RGB32, semi-red") << QImage::Format_RGB32 << 0x80ff0000u << 0xffff0000u;
|
||||
QTest::newRow("ARGB32, semi-red") << QImage::Format_ARGB32 << 0x80ff0000u << 0x80ff0000u;
|
||||
QTest::newRow("ARGB32pm, semi-red") << QImage::Format_ARGB32 << 0x80800000u << 0x80800000u;
|
||||
QTest::newRow("RGBA8888pm, semi-red") << QImage::Format_RGBA8888_Premultiplied << 0x80000080u << 0x80800000u;
|
||||
QTest::newRow("Alpha8, semi-red") << QImage::Format_Alpha8 << 0x80000080u << 0x80000000u;
|
||||
|
||||
QTest::newRow("Alpha8, semi-transparent") << QImage::Format_Alpha8 << 0x80u << 0x80000000u;
|
||||
}
|
||||
|
||||
void tst_QImage::fillPixel()
|
||||
@ -2436,6 +2440,8 @@ void tst_QImage::fillPixel()
|
||||
|
||||
image.fill(color);
|
||||
QCOMPARE(image.pixel(0, 0), pixelValue);
|
||||
if (image.depth() == 8)
|
||||
QCOMPARE(*(const uchar *)image.constBits(), color);
|
||||
}
|
||||
|
||||
void tst_QImage::rgbSwapped_data()
|
||||
|
Loading…
x
Reference in New Issue
Block a user