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 <eirik.aavitsland@qt.io>
This commit is contained in:
Allan Sandfeld Jensen 2016-12-07 13:03:44 +01:00
parent 074b9f1eef
commit f882d2f443
2 changed files with 18 additions and 2 deletions

View File

@ -217,8 +217,8 @@ static const QRgba64 *QT_FASTCALL convertToRGB64(QRgba64 *buffer, const uint *sr
uint green = (src[i] >> greenShift<Format>()) & greenMask;
uint blue = (src[i] >> blueShift<Format>()) & 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);
}

View File

@ -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"