Commit 33d6203c authored by Daniel Novomeský's avatar Daniel Novomeský Committed by Daniel Novomeský
Browse files

Convert image to original format to enable correct color correction

QImage::scaled() may unexpectedly change image’s format to Premultiplied,
we need to ensure that image remains in original format supported by
color correction engine.
parent 514e35ae
......@@ -114,6 +114,8 @@ void RasterImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *
image = mSixthScaledImage.copy(sourceRect);
}
const QImage::Format originalImageFormat = image.format();
// We want nearest neighbour when zooming in since that provides the most
// accurate representation of pixels, but when zooming out it will actually
// not look very nice, so use smoothing when zooming out.
......@@ -122,6 +124,12 @@ void RasterImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *
// Scale the visible image to the requested zoom.
image = image.scaled(image.size() * targetZoom, Qt::IgnoreAspectRatio, transformationMode);
// Scaling may convert image to premultiplied formats (unsupported by color correction engine),
// so we convert image back to originalImageFormat.
if (image.format() != originalImageFormat) {
image.convertTo(originalImageFormat);
}
// Perform color correction on the visible image.
applyDisplayTransform(image);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment