From f882d2f443a8950a2f784fa91b3ff10a645577f7 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 7 Dec 2016 13:03:44 +0100 Subject: [PATCH] Fix qdrawhelper function toRGB64 The function was incorrectly handling green and blue color channels causing them to be dropped. This affects drawing non 32-bit images onto 10-bit per color channels formats such as RGB30. Change-Id: I9211e253b1a9da0dada5c418d592a8f531265989 Reviewed-by: Eirik Aavitsland --- src/gui/painting/qdrawhelper.cpp | 4 ++-- .../auto/gui/painting/qpainter/tst_qpainter.cpp | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 64956d342df..8700a0fce16 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -217,8 +217,8 @@ static const QRgba64 *QT_FASTCALL convertToRGB64(QRgba64 *buffer, const uint *sr uint green = (src[i] >> greenShift()) & greenMask; uint blue = (src[i] >> blueShift()) & blueMask; - red = ((red << redLeftShift) | (red >> redRightShift)) << 16; - green = ((green << greenLeftShift) | (green >> greenRightShift)) << 8; + red = ((red << redLeftShift) | (red >> redRightShift)); + green = ((green << greenLeftShift) | (green >> greenRightShift)); blue = (blue << blueLeftShift) | (blue >> blueRightShift); buffer[i] = QRgba64::fromRgba(red, green, blue, 255); } diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index c729b2f94c8..cf4979e2917 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -301,6 +301,7 @@ private slots: void QTBUG56252(); void blendNullRGB32(); + void toRGB64(); private: void fillData(); @@ -5159,6 +5160,21 @@ void tst_QPainter::blendNullRGB32() QVERIFY(image.pixel(i,0) != 0xffffffff); } +void tst_QPainter::toRGB64() +{ + QImage dst(10, 1, QImage::Format_BGR30); + QImage src(10, 1, QImage::Format_RGB16); + src.fill(Qt::white); + + QPainter paint(&dst); + paint.drawImage(0, 0, src); + paint.end(); + + for (int i=0; i < dst.width(); ++i) { + QVERIFY(dst.pixelColor(i,0) == QColor(Qt::white)); + } +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc"