Preserve QImage metadata when converting format with color table
Unlike the other conversion functions, convertWithPalette() did not call copyMetadata(). Fixes: QTBUG-96926 Pick-to: 6.2 5.15 Change-Id: I2b171cec16bc5a90d33e80d6fe178c650ed3fe36 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
parent
a2ab67c8b2
commit
66a44f4eba
@ -2231,7 +2231,7 @@ static QImage convertWithPalette(const QImage &src, QImage::Format format,
|
|||||||
QImage dest(src.size(), format);
|
QImage dest(src.size(), format);
|
||||||
dest.setColorTable(clut);
|
dest.setColorTable(clut);
|
||||||
|
|
||||||
QImageData::get(dest)->text = QImageData::get(src)->text;
|
copyMetadata(QImageData::get(dest), QImageData::get(src));
|
||||||
|
|
||||||
int h = src.height();
|
int h = src.height();
|
||||||
int w = src.width();
|
int w = src.width();
|
||||||
|
@ -3671,6 +3671,13 @@ void tst_QImage::metadataPassthrough()
|
|||||||
QCOMPARE(converted.dotsPerMeterY(), a.dotsPerMeterY());
|
QCOMPARE(converted.dotsPerMeterY(), a.dotsPerMeterY());
|
||||||
QCOMPARE(converted.devicePixelRatio(), a.devicePixelRatio());
|
QCOMPARE(converted.devicePixelRatio(), a.devicePixelRatio());
|
||||||
|
|
||||||
|
QList<QRgb> clut({ 0xFFFF0000, 0xFF00FF00, 0xFF0000FF });
|
||||||
|
QImage convertedWithClut = a.convertToFormat(QImage::Format_Indexed8, clut);
|
||||||
|
QCOMPARE(convertedWithClut.text(QStringLiteral("Test")), a.text(QStringLiteral("Test")));
|
||||||
|
QCOMPARE(convertedWithClut.dotsPerMeterX(), a.dotsPerMeterX());
|
||||||
|
QCOMPARE(convertedWithClut.dotsPerMeterY(), a.dotsPerMeterY());
|
||||||
|
QCOMPARE(convertedWithClut.devicePixelRatio(), a.devicePixelRatio());
|
||||||
|
|
||||||
QImage copied = a.copy(0, 0, a.width() / 2, a.height() / 2);
|
QImage copied = a.copy(0, 0, a.width() / 2, a.height() / 2);
|
||||||
QCOMPARE(copied.text(QStringLiteral("Test")), a.text(QStringLiteral("Test")));
|
QCOMPARE(copied.text(QStringLiteral("Test")), a.text(QStringLiteral("Test")));
|
||||||
QCOMPARE(copied.dotsPerMeterX(), a.dotsPerMeterX());
|
QCOMPARE(copied.dotsPerMeterX(), a.dotsPerMeterX());
|
||||||
|
Loading…
Reference in New Issue
Block a user