Bug 493432

Summary: Background color not filling in entire window
Product: [Applications] gwenview Reporter: Andre Kalouguine <andre.kalouguine.ak>
Component: generalAssignee: Gwenview Bugs <gwenview-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: 1900011604, bizyaev, justin, me, viz, zawertun
Priority: NOR    
Version First Reported In: 24.12.1   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 25.12
Sentry Crash Report:
Attachments: A video recording of the problem
Patch
Gwenview displaying after patch applied

Description Andre Kalouguine 2024-09-21 12:17:15 UTC
Created attachment 173932 [details]
A video recording of the problem

SUMMARY
Opening a large png image with transparency and turning on either "Solid colour background" or "Checkerboard background" results in the background only filling in the top left part of the image. The rest still has the default dark-gray background.

STEPS TO REPRODUCE
1. Go to Gwenview settings, turn on "Solid colour background"
2. Open large PNG image with transparency. Example I used: the 2D example at https://github.com/amv213/ComponentLibrary

OBSERVED RESULT
Only top left part of image gets the requested background

EXPECTED RESULT
Solid white background over the whole image

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.1.5
KDE Frameworks Version: 6.5.0
Qt Version: 6.7.2
Kernel Version: 6.10.9-arch1-2 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 9 7940HS w/ Radeon 780M Graphics
Memory: 90.2 GiB of RAM
Graphics Processor: AMD Radeon 780M

ADDITIONAL INFORMATION
Zooming in results in the background being bigger than the window (I guess) and the problem is hidden.
Comment 1 Justin Zobel 2024-09-24 11:37:11 UTC
Can confirm this issue on git master using the provided sample file and a white background.
Comment 2 Ilya Bizyaev 2024-10-26 18:52:39 UTC
Same here with the checkerboard background.
Comment 3 Ilya Bizyaev 2025-01-17 16:30:12 UTC
*** Bug 460313 has been marked as a duplicate of this bug. ***
Comment 4 Yaroslav Sidlovsky 2025-01-18 08:40:16 UTC
I can confirm this bug.

The error is that width and height on lines 58 and 59 here https://invent.kde.org/graphics/gwenview/-/blob/6d6dc993be05d8627086464305d4f00815de9845/lib/documentview/alphabackgrounditem.cpp#L58
accounts `devicePixelRatio()` value, although `painter->drawTiledPixmap()` already draws using `devicePixelRatio()`.

Url for testing bug: https://raw.githubusercontent.com/amv213/ComponentLibrary/6446e922464240e3de5fcea8aa30266d0c46114c/imgs/2D_demo.png.

One line command to test it from console:
```
gwenview https://raw.githubusercontent.com/amv213/ComponentLibrary/6446e922464240e3de5fcea8aa30266d0c46114c/imgs/2D_demo.png
```
Comment 5 Yaroslav Sidlovsky 2025-01-18 08:40:50 UTC
Created attachment 177488 [details]
Patch
Comment 6 Yaroslav Sidlovsky 2025-01-18 08:48:27 UTC
Created attachment 177489 [details]
Gwenview displaying after patch applied

Is it displaying OK?
Comment 7 Bug Janitor Service 2025-01-18 14:08:11 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/gwenview/-/merge_requests/313
Comment 8 John Kizer 2025-06-11 05:02:39 UTC
*** Bug 504953 has been marked as a duplicate of this bug. ***
Comment 9 Wenxuan Zhao 2025-08-12 05:53:01 UTC
The patch doesn't work for me since I have 175% scale, so I created https://invent.kde.org/graphics/gwenview/-/merge_requests/343 to use painter->device()->devicePixelRatioF() to get the correct scale factor
Comment 10 Ilya Bizyaev 2025-08-24 14:54:44 UTC
This has now been fixed by Wenxuan Zhao in https://invent.kde.org/graphics/gwenview/-/merge_requests/343!