Bug 459627

Summary: Strange artifacting / dithering on zoom with some pngs
Product: [Applications] gwenview Reporter: nathan
Component: generalAssignee: Gwenview Bugs <gwenview-bugs-null>
Status: ASSIGNED ---    
Severity: normal CC: 1nikolas, jmsharvey771, karl, kde.h8bcay, kde, niccolo.venerandi, nyanpasu64, starfr_fornr, wolftune
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Manjaro   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Sample.png
100x
200x
141x
400x
Gwenview-artifacts not Okular
A solid red image, created with convert -size 500x1000 "xc:rgb(224,0,0)" 224.png
Red screenshot
Full colour image (no problems when zooming)
Indexed image (noise pattern when zooming)

Description nathan 2022-09-24 23:36:28 UTC
Created attachment 152393 [details]
Sample.png

SUMMARY
When zooming on certain PNG images, a strange artifacting or dithering appears at certain zoom levels. In the case of Sample.png (attached), 100% and 400% are unaffected, but all zoom levels in-between show this bug.

STEPS TO REPRODUCE
* Open Sample.png
* Zoom

OBSERVED RESULT
Strange image rendering


SOFTWARE/OS VERSIONS
KDE Plasma Version: 5.25.5
KDE Frameworks Version: 5.97.0
Qt Version: 5.15.5
Comment 1 nathan 2022-09-24 23:36:46 UTC
Created attachment 152394 [details]
100x
Comment 2 nathan 2022-09-24 23:36:56 UTC
Created attachment 152395 [details]
200x
Comment 3 nathan 2022-09-24 23:37:14 UTC
Created attachment 152396 [details]
141x
Comment 4 nathan 2022-09-24 23:37:34 UTC
Created attachment 152397 [details]
400x
Comment 5 veggero 2022-09-25 15:34:08 UTC
Can reproduce
Comment 6 Aaron Wolf 2022-10-13 18:39:24 UTC
Created attachment 152784 [details]
Gwenview-artifacts not Okular

Same pngquant-processed png file, Okular is fine, Gwenview has artifacts
Comment 7 Aaron Wolf 2022-10-13 18:39:34 UTC
I found this shows up with png files that were processed with pngquant. The original file looks fine in gwenview. The processed file still looks fine in Firefox and in Okular, but it is glitchy in gwenview when zoomed in or out.

Adding an attachment of the exact same pngquant-processed file zoomed in Okular and Gwenview, unprocessed PNG screenshot showing only Gwenview with the artifacts.
Comment 8 jmsharvey771 2023-04-27 14:58:11 UTC
Created attachment 158487 [details]
A solid red image, created with convert -size 500x1000 "xc:rgb(224,0,0)" 224.png

This solid red image (created with the ImageMagick command convert -size 500x1000 "xc:rgb(224,0,0)" 224.png) appears totally broken when zoomed in.
Comment 9 jmsharvey771 2023-04-27 14:59:16 UTC
Created attachment 158488 [details]
Red screenshot

Screenshot of the above image being viewed at 200%. This is on Arch, with Gwenview 23.04.0-1
Comment 10 Karl Ove Hufthammer 2023-06-28 06:52:17 UTC
It also happens with indexed PNG images *not* processed by pngquant. I’ll attach two images. The first is a full-colour PNG image (23,808 colours) image. The second is the same image, but as an indexed PNG image where the number of colours have been reduced to 120 using Gimp, but *without* any dithering applied (so it’s not a dithering problem).

The first image look fine when zoomed, but the other has this strange noisy pattern on most zoom levels (not at *exactly* 100% or levels above 400%, but at all other zoom levels, AFAICS).
Comment 11 Karl Ove Hufthammer 2023-06-28 06:52:50 UTC
Created attachment 159945 [details]
Full colour image (no problems when zooming)
Comment 12 Karl Ove Hufthammer 2023-06-28 06:53:22 UTC
Created attachment 159946 [details]
Indexed image (noise pattern when zooming)
Comment 13 Karl Ove Hufthammer 2023-06-28 09:51:44 UTC
I did a quick Git bisect. The bug was introduced in this commit:

commit 33d6203c7b4de83a8a1ea92dfc7036af87eb43f2
Author: Daniel Novomesky <dnovomesky@gmail.com>
Date:   Mon Sep 6 19:56:30 2021 +0200

    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.
Comment 14 Karl Ove Hufthammer 2023-06-28 09:59:26 UTC
*** Bug 471194 has been marked as a duplicate of this bug. ***
Comment 15 SkyWalteron 2024-09-12 01:56:32 UTC
*** Bug 491696 has been marked as a duplicate of this bug. ***
Comment 16 Bug Janitor Service 2024-09-28 05:03:05 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/gwenview/-/merge_requests/293