Color management problem for images with alpha channel
Hello,
I observed that color management sometimes doesn't work when image has alpha channel/transparency.
I am attaching testfiles.zip
When I view them in gwenview, it is clear that color management was not applied to the image (image is dark):
The image should look this way:
There is an error in the terminal:
org.kde.kdegraphics.gwenview.lib: Gwenview cannot apply color profile on QImage::Format_ARGB32_Premultiplied images
or
org.kde.kdegraphics.gwenview.lib: Gwenview cannot apply color profile on QImage::Format_RGBA64_Premultiplied images
Of course, lcms2 cannot apply color profile on Premultiplied images. But the images are loaded in QImage::Format_ARGB32
or QImage::Format_RGBA64
and something inside gwenview caused that the image is somehow converted to Premultiplied formats which disables color management.
The problematic place where conversion to Premultiplied is taking place is following line in rasterimageitem.cpp:
// Scale the visible image to the requested zoom.
image = image.scaled(image.size() * targetZoom, Qt::IgnoreAspectRatio, transformationMode);
The QImage::scaled
at some zoom levels convert transparent images to Premultiplied formats. I don't know why, but it really behaves that way sometimes (not all the time).
I would suggest that we can move applyDisplayTransform(image);
before scaling so that color management could be performed when the image is not premultipied yet.
What do you think? Otherwise we would need alternative scaling function.