diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 175ff8cc49..87959177c7 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -4718,7 +4718,7 @@ static QImage rotated90(const QImage &image) QImage out(image.height(), image.width(), image.format()); if (out.isNull()) return out; - copyMetadata(&out, image); + copyMetadata(QImageData::get(out), QImageData::get(image)); if (image.colorCount() > 0) out.setColorTable(image.colorTable()); int w = image.width(); @@ -4748,7 +4748,7 @@ static QImage rotated180(const QImage &image) QImage out(image.width(), image.height(), image.format()); if (out.isNull()) return out; - copyMetadata(&out, image); + copyMetadata(QImageData::get(out), QImageData::get(image)); if (image.colorCount() > 0) out.setColorTable(image.colorTable()); int w = image.width(); @@ -4762,7 +4762,7 @@ static QImage rotated270(const QImage &image) QImage out(image.height(), image.width(), image.format()); if (out.isNull()) return out; - copyMetadata(&out, image); + copyMetadata(QImageData::get(out), QImageData::get(image)); if (image.colorCount() > 0) out.setColorTable(image.colorTable()); int w = image.width(); diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 8086ffcc28..5b20894831 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -3997,24 +3997,28 @@ void tst_QImage::metadataPassthrough() a.setDotsPerMeterX(100); a.setDotsPerMeterY(80); a.setDevicePixelRatio(2.0); + a.setColorSpace(QColorSpace(QColorSpace::DisplayP3)); QImage scaled = a.scaled(QSize(32, 32), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); QCOMPARE(scaled.text(QStringLiteral("Test")), a.text(QStringLiteral("Test"))); QCOMPARE(scaled.dotsPerMeterX(), a.dotsPerMeterX()); QCOMPARE(scaled.dotsPerMeterY(), a.dotsPerMeterY()); QCOMPARE(scaled.devicePixelRatio(), a.devicePixelRatio()); + QCOMPARE(scaled.colorSpace(), a.colorSpace()); scaled = a.scaled(QSize(128, 128), Qt::IgnoreAspectRatio, Qt::FastTransformation); QCOMPARE(scaled.text(QStringLiteral("Test")), a.text(QStringLiteral("Test"))); QCOMPARE(scaled.dotsPerMeterX(), a.dotsPerMeterX()); QCOMPARE(scaled.dotsPerMeterY(), a.dotsPerMeterY()); QCOMPARE(scaled.devicePixelRatio(), a.devicePixelRatio()); + QCOMPARE(scaled.colorSpace(), a.colorSpace()); QImage mirrored = a.mirrored(); QCOMPARE(mirrored.text(QStringLiteral("Test")), a.text(QStringLiteral("Test"))); QCOMPARE(mirrored.dotsPerMeterX(), a.dotsPerMeterX()); QCOMPARE(mirrored.dotsPerMeterY(), a.dotsPerMeterY()); QCOMPARE(mirrored.devicePixelRatio(), a.devicePixelRatio()); + QCOMPARE(mirrored.colorSpace(), a.colorSpace()); QTransform t; t.rotate(90); @@ -4023,18 +4027,21 @@ void tst_QImage::metadataPassthrough() QCOMPARE(rotated.dotsPerMeterX(), a.dotsPerMeterX()); QCOMPARE(rotated.dotsPerMeterY(), a.dotsPerMeterY()); QCOMPARE(rotated.devicePixelRatio(), a.devicePixelRatio()); + QCOMPARE(rotated.colorSpace(), a.colorSpace()); QImage swapped = a.rgbSwapped(); QCOMPARE(swapped.text(QStringLiteral("Test")), a.text(QStringLiteral("Test"))); QCOMPARE(swapped.dotsPerMeterX(), a.dotsPerMeterX()); QCOMPARE(swapped.dotsPerMeterY(), a.dotsPerMeterY()); QCOMPARE(swapped.devicePixelRatio(), a.devicePixelRatio()); + QCOMPARE(swapped.colorSpace(), a.colorSpace()); QImage converted = a.convertToFormat(QImage::Format_RGB32); QCOMPARE(converted.text(QStringLiteral("Test")), a.text(QStringLiteral("Test"))); QCOMPARE(converted.dotsPerMeterX(), a.dotsPerMeterX()); QCOMPARE(converted.dotsPerMeterY(), a.dotsPerMeterY()); QCOMPARE(converted.devicePixelRatio(), a.devicePixelRatio()); + QCOMPARE(converted.colorSpace(), a.colorSpace()); QList clut({ 0xFFFF0000, 0xFF00FF00, 0xFF0000FF }); QImage convertedWithClut = a.convertToFormat(QImage::Format_Indexed8, clut); @@ -4042,12 +4049,14 @@ void tst_QImage::metadataPassthrough() QCOMPARE(convertedWithClut.dotsPerMeterX(), a.dotsPerMeterX()); QCOMPARE(convertedWithClut.dotsPerMeterY(), a.dotsPerMeterY()); QCOMPARE(convertedWithClut.devicePixelRatio(), a.devicePixelRatio()); + QCOMPARE(convertedWithClut.colorSpace(), a.colorSpace()); QImage copied = a.copy(0, 0, a.width() / 2, a.height() / 2); QCOMPARE(copied.text(QStringLiteral("Test")), a.text(QStringLiteral("Test"))); QCOMPARE(copied.dotsPerMeterX(), a.dotsPerMeterX()); QCOMPARE(copied.dotsPerMeterY(), a.dotsPerMeterY()); QCOMPARE(copied.devicePixelRatio(), a.devicePixelRatio()); + QCOMPARE(copied.colorSpace(), a.colorSpace()); QImage alphaMask = a.createAlphaMask(); QCOMPARE(alphaMask.dotsPerMeterX(), a.dotsPerMeterX());