Bug 459627 - Strange artifacting / dithering on zoom with some pngs
Summary: Strange artifacting / dithering on zoom with some pngs
Status: RESOLVED FIXED
Alias: None
Product: gwenview
Classification: Applications
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Manjaro Linux
: NOR normal
Target Milestone: ---
Assignee: Gwenview Bugs
URL:
Keywords:
: 471194 491696 496597 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-09-24 23:36 UTC by Nathan Upchurch
Modified: 2024-12-07 16:29 UTC (History)
10 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Sample.png (15.97 KB, image/png)
2022-09-24 23:36 UTC, Nathan Upchurch
Details
100x (216.09 KB, image/png)
2022-09-24 23:36 UTC, Nathan Upchurch
Details
200x (754.95 KB, image/png)
2022-09-24 23:36 UTC, Nathan Upchurch
Details
141x (589.99 KB, image/png)
2022-09-24 23:37 UTC, Nathan Upchurch
Details
400x (192.56 KB, image/png)
2022-09-24 23:37 UTC, Nathan Upchurch
Details
Gwenview-artifacts not Okular (370.54 KB, image/png)
2022-10-13 18:39 UTC, Aaron Wolf
Details
A solid red image, created with convert -size 500x1000 "xc:rgb(224,0,0)" 224.png (236 bytes, image/png)
2023-04-27 14:58 UTC, jmsharvey771
Details
Red screenshot (474.50 KB, image/png)
2023-04-27 14:59 UTC, jmsharvey771
Details
Full colour image (no problems when zooming) (384.19 KB, image/png)
2023-06-28 06:52 UTC, Karl Ove Hufthammer
Details
Indexed image (noise pattern when zooming) (98.06 KB, image/png)
2023-06-28 06:53 UTC, Karl Ove Hufthammer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Upchurch 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 Upchurch 2022-09-24 23:36:46 UTC
Created attachment 152394 [details]
100x
Comment 2 Nathan Upchurch 2022-09-24 23:36:56 UTC
Created attachment 152395 [details]
200x
Comment 3 Nathan Upchurch 2022-09-24 23:37:14 UTC
Created attachment 152396 [details]
141x
Comment 4 Nathan Upchurch 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
Comment 17 nyanpasu64 2024-11-13 10:05:32 UTC
Git commit 3d52a2694314629491e0b3720608f349978ea8de by Tabby Kitten.
Committed on 13/11/2024 at 04:31.
Pushed by felixernst into branch 'master'.

Fix garbled colors when scaling indexed-color images

Fixes bug where indexed-color or monochrome-palette images (eg. from
pngquant) would render with garbled colors or B&W noise when zoomed.

I converted images from indexed colors to (A)RGB32, to avoid error
"Gwenview cannot apply color profile on QImage::... images" (depending
on zoom level).

I verified that wide-gamut images (Webkit-logo-P3.png) are still clipped
to SDR gamut. I tested that wide-gamut indexed images are now properly
clipped, but these images are probably ahistorical.

Bug introduced by commit 33d6203c7b4de83a8a1ea92dfc7036af87eb43f2.

M  +9    -3    lib/documentview/rasterimageitem.cpp

https://invent.kde.org/graphics/gwenview/-/commit/3d52a2694314629491e0b3720608f349978ea8de
Comment 18 Carl Schwan 2024-11-16 22:13:06 UTC
Git commit c6d3070a0c705ab71fc1c3a85d37d905f190f1c8 by Carl Schwan, on behalf of Tabby Kitten.
Committed on 16/11/2024 at 22:14.
Pushed by carlschwan into branch 'release/24.12'.

Fix garbled colors when scaling indexed-color images

Fixes bug where indexed-color or monochrome-palette images (eg. from
pngquant) would render with garbled colors or B&W noise when zoomed.

I converted images from indexed colors to (A)RGB32, to avoid error
"Gwenview cannot apply color profile on QImage::... images" (depending
on zoom level).

I verified that wide-gamut images (Webkit-logo-P3.png) are still clipped
to SDR gamut. I tested that wide-gamut indexed images are now properly
clipped, but these images are probably ahistorical.

Bug introduced by commit 33d6203c7b4de83a8a1ea92dfc7036af87eb43f2.

(cherry picked from commit 3d52a2694314629491e0b3720608f349978ea8de)

M  +9    -3    lib/documentview/rasterimageitem.cpp

https://invent.kde.org/graphics/gwenview/-/commit/c6d3070a0c705ab71fc1c3a85d37d905f190f1c8
Comment 19 John Kizer 2024-12-07 16:29:22 UTC
*** Bug 496597 has been marked as a duplicate of this bug. ***