Fix smooth scaling of Format_Mono and Format_MonoLSB
Fixes: QTBUG-117713 Pick-to: 6.6 6.5 6.2 Change-Id: I2fb071a4d2229da50dfacb0a92c51c3e4ea57a74 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
parent
c5d9e4a7a7
commit
799bfe94e8
@ -4862,14 +4862,24 @@ QImage Q_TRACE_INSTRUMENT(qtgui) QImage::transformed(const QTransform &matrix, Q
|
|||||||
|| (ws * hs) >= (1<<20)
|
|| (ws * hs) >= (1<<20)
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
|
QImage scaledImage;
|
||||||
if (mat.m11() < 0.0F && mat.m22() < 0.0F) { // horizontal/vertical flip
|
if (mat.m11() < 0.0F && mat.m22() < 0.0F) { // horizontal/vertical flip
|
||||||
return smoothScaled(wd, hd).mirrored(true, true).convertToFormat(format());
|
scaledImage = smoothScaled(wd, hd).mirrored(true, true);
|
||||||
} else if (mat.m11() < 0.0F) { // horizontal flip
|
} else if (mat.m11() < 0.0F) { // horizontal flip
|
||||||
return smoothScaled(wd, hd).mirrored(true, false).convertToFormat(format());
|
scaledImage = smoothScaled(wd, hd).mirrored(true, false);
|
||||||
} else if (mat.m22() < 0.0F) { // vertical flip
|
} else if (mat.m22() < 0.0F) { // vertical flip
|
||||||
return smoothScaled(wd, hd).mirrored(false, true).convertToFormat(format());
|
scaledImage = smoothScaled(wd, hd).mirrored(false, true);
|
||||||
} else { // no flipping
|
} else { // no flipping
|
||||||
return smoothScaled(wd, hd).convertToFormat(format());
|
scaledImage = smoothScaled(wd, hd);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (format()) {
|
||||||
|
case QImage::Format_Mono:
|
||||||
|
case QImage::Format_MonoLSB:
|
||||||
|
case QImage::Format_Indexed8:
|
||||||
|
return scaledImage;
|
||||||
|
default:
|
||||||
|
return scaledImage.convertToFormat(format());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,6 +108,8 @@ private slots:
|
|||||||
void smoothScaleAlpha();
|
void smoothScaleAlpha();
|
||||||
void smoothScaleFormats_data();
|
void smoothScaleFormats_data();
|
||||||
void smoothScaleFormats();
|
void smoothScaleFormats();
|
||||||
|
void smoothScaleNoConversion_data();
|
||||||
|
void smoothScaleNoConversion();
|
||||||
|
|
||||||
void transformed_data();
|
void transformed_data();
|
||||||
void transformed();
|
void transformed();
|
||||||
@ -2058,6 +2060,24 @@ void tst_QImage::smoothScaleFormats()
|
|||||||
QVERIFY(rotated.hasAlphaChannel());
|
QVERIFY(rotated.hasAlphaChannel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QImage::smoothScaleNoConversion_data()
|
||||||
|
{
|
||||||
|
QTest::addColumn<QImage::Format>("format");
|
||||||
|
QTest::addRow("Mono") << QImage::Format_Mono;
|
||||||
|
QTest::addRow("MonoLSB") << QImage::Format_MonoLSB;
|
||||||
|
QTest::addRow("Indexed8") << QImage::Format_Indexed8;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QImage::smoothScaleNoConversion()
|
||||||
|
{
|
||||||
|
QFETCH(QImage::Format, format);
|
||||||
|
QImage img(128, 128, format);
|
||||||
|
img.fill(1);
|
||||||
|
img.setColorTable(QList<QRgb>() << qRgba(255,0,0,255) << qRgba(0,0,0,0));
|
||||||
|
img = img.scaled(QSize(48, 48), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
|
QVERIFY(img.hasAlphaChannel());
|
||||||
|
}
|
||||||
|
|
||||||
static int count(const QImage &img, int x, int y, int dx, int dy, QRgb pixel)
|
static int count(const QImage &img, int x, int y, int dx, int dy, QRgb pixel)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user