Copy color table in QImage::transform paint path
A copy without pixel ratio was made, but color table not set. Pick-to: 6.5 6.2 Fixes: QTBUG-119902 Change-Id: I328f3faa70d7a1263061cbe51921999393e30801 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit 15051e205facddd8bc3f290c65ad854ec1b25091) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 993db3ee9a1759a858c1968f831339f8a6130d88)
This commit is contained in:
parent
4ba4525b5a
commit
4c674c8bde
@ -4921,7 +4921,14 @@ QImage Q_TRACE_INSTRUMENT(qtgui) QImage::transformed(const QTransform &matrix, Q
|
||||
|
||||
if (target_format >= QImage::Format_RGB32) {
|
||||
// Prevent QPainter from applying devicePixelRatio corrections
|
||||
const QImage sImage = (devicePixelRatio() != 1) ? QImage(constBits(), width(), height(), format()) : *this;
|
||||
QImage sImage = (devicePixelRatio() != 1) ? QImage(constBits(), width(), height(), format()) : *this;
|
||||
if (sImage.d != d
|
||||
&& (d->format == QImage::Format_MonoLSB
|
||||
|| d->format == QImage::Format_Mono
|
||||
|| d->format == QImage::Format_Indexed8)) {
|
||||
sImage.d->colortable = d->colortable;
|
||||
sImage.d->has_alpha_clut = d->has_alpha_clut;
|
||||
}
|
||||
|
||||
Q_ASSERT(sImage.devicePixelRatio() == 1);
|
||||
Q_ASSERT(sImage.devicePixelRatio() == dImage.devicePixelRatio());
|
||||
|
@ -231,6 +231,7 @@ private slots:
|
||||
void largeRasterScale();
|
||||
|
||||
void metadataChangeWithReadOnlyPixels();
|
||||
void scaleIndexed();
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
void toWinHBITMAP_data();
|
||||
@ -4099,6 +4100,16 @@ void tst_QImage::metadataChangeWithReadOnlyPixels()
|
||||
QCOMPARE(image.constBits(), (const uchar *)data);
|
||||
}
|
||||
|
||||
void tst_QImage::scaleIndexed()
|
||||
{
|
||||
QImage image(10, 10, QImage::Format_Indexed8);
|
||||
image.setColor(0, qRgb(0,0,0));
|
||||
image.setColor(1, qRgb(1,1,1));
|
||||
image.fill(1);
|
||||
image.setDevicePixelRatio(2);
|
||||
QImage image2 = image.scaled(20, 20, Qt::KeepAspectRatio, Qt::SmoothTransformation); // do not crash
|
||||
}
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
|
||||
static inline QColor COLORREFToQColor(COLORREF cr)
|
||||
|
Loading…
x
Reference in New Issue
Block a user