Commit 4e26fe2c authored by Nate Graham's avatar Nate Graham
Browse files

Only switch to Qt::FastTransformation ("showing pixels") at 500% zoom

Right now Gwenview uses Qt::FastTransformation to show individual pixels
at any zoom value higher than 100%. This is not optimal and results in
poor display for low zoom levels where a smoothed image is more
aesthetically desirable. But there are use cases for seeing individual
pixels--for example when looking at the details of a line-art graphic
or an icon, or examing an image to see its individual colors. These use
cases becomes more likely as the zoom level is increased.

Accordingly, this commit changes Gwenview to shop smoothing zoomed-in
images at an arbitrarily-chosen threshold of 400% zoom. At that level or
above, the image will be unsmoothed and you can see the individual
hard-edged pixels.

BUG: 443010
FIXED-IN: 22.04
parent 298e6190
Pipeline #106996 passed with stage
in 5 minutes and 47 seconds
......@@ -116,10 +116,11 @@ void RasterImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *
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.
const auto transformationMode = zoom < 1.0 ? Qt::SmoothTransformation : Qt::FastTransformation;
// We want nearest neighbour at high zoom since that provides the most
// accurate representation of pixels, but at low zoom or when zooming out it
// will not look very nice, so use smoothing instead. Switch at an arbitrary
// threshold of 400% zoom
const auto transformationMode = zoom < 4.0 ? Qt::SmoothTransformation : Qt::FastTransformation;
// Scale the visible image to the requested zoom.
image = image.scaled(image.size() * targetZoom, Qt::IgnoreAspectRatio, transformationMode);
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