Bug 411118

Summary: Reference image renders at half native resolution on high DPI displays.
Product: [Applications] krita Reporter: Ralek Kolemios <info>
Component: Tools/Reference ImagesAssignee: Tiar <tamtamy.tymona>
Status: RESOLVED FIXED    
Severity: minor CC: halla, info, tamtamy.tymona
Priority: NOR    
Version: nightly build (please specify the git hash!)   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: File showing the difference
Screenshot showing the difference on 4k display (ref image on the right)

Description Ralek Kolemios 2019-08-21 02:02:02 UTC
SUMMARY
Reference images imported to the canvas are rendered at lower than native resolution on high resolution displays. (In this case, 4k)

STEPS TO REPRODUCE
1. Import a reference image
2. Compare its rendered resolution to native

OBSERVED RESULT
The reference image seems to be rendered at around half native resolution.

EXPECTED RESULT
The reference image renders at native resolution.

Krita
  Version: 4.3.0-prealpha (git 5533582)
Qt
  Version (compiled): 5.12.4
  Version (loaded): 5.12.4
OS Information
  Build ABI: x86_64-little_endian-llp64
  Build CPU: x86_64
  CPU: x86_64
  Kernel Type: winnt
  Kernel Version: 10.0.16299
  Pretty Productname: Windows 10 (10.0)
  Product Type: windows
  Product Version: 10


ADDITIONAL INFORMATION
This may be expected behavior to raise performance, I'm not sure.
Comment 1 Halla Rempt 2019-08-27 11:57:27 UTC
Hi Aaron,

I'm not sure I can actually see this, but it's probably caused by the way the canvas handles hidpi internally. I'm not sure what we can do about it.
Comment 2 Tiar 2020-10-16 20:48:36 UTC
Created attachment 132446 [details]
File showing the difference

I can see it clearly with a 100x100 file attached.
Comment 3 Tiar 2020-10-16 20:49:07 UTC
Created attachment 132447 [details]
Screenshot showing the difference on 4k display (ref image on the right)
Comment 4 Bug Janitor Service 2020-10-20 22:40:25 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/545
Comment 5 Tiar 2020-10-26 18:15:42 UTC
Git commit 5c6a7229bc61aa075416540b4d0da1a4e51dc293 by Agata Cacko.
Committed on 26/10/2020 at 18:13.
Pushed by tymond into branch 'master'.

Fix seexpr icon to be high res on high dpi displays

Before this commit, the icon of the seexpr script would be drawn in
a low resolution (a result of UI scaling). After this commit
the icon is drawn in a highest possible resolution.

M  +4    -1    plugins/generators/seexpr/kis_wdg_seexpr.cpp

https://invent.kde.org/graphics/krita/commit/5c6a7229bc61aa075416540b4d0da1a4e51dc293
Comment 6 Halla Rempt 2020-10-28 09:25:01 UTC
Git commit fb247f6a6d87a3faf90f75a00a91d4be1335978c by Boudewijn Rempt, on behalf of Agata Cacko.
Committed on 28/10/2020 at 09:24.
Pushed by rempt into branch 'master'.

Remove the workaround border from the ref images

Before this commit, Reference Images would use the same workaround
as the brush tips since they all use KisQImagePyramid.
However it is not needed for Reference Images and creates
an empty margin around the images.

This commit adds a new method to KisQImagePyramid to get the image
without the workaround border.
(The workaround is just 1 pixel of transparency around the whole edge
that KisQImagePyramid is returning as the closest mipmap image).

M  +9    -0    libs/brush/kis_qimage_pyramid.cpp
M  +2    -0    libs/brush/kis_qimage_pyramid.h
M  +1    -1    libs/ui/KisReferenceImage.cpp

https://invent.kde.org/graphics/krita/commit/fb247f6a6d87a3faf90f75a00a91d4be1335978c
Comment 7 Halla Rempt 2020-10-28 09:25:09 UTC
Git commit 1d8b94e3c545b5d2ac98242dd14c6c0becb17071 by Boudewijn Rempt, on behalf of Agata Cacko.
Committed on 28/10/2020 at 09:24.
Pushed by rempt into branch 'master'.

Draw reference images in high res on 4k display

Before this commit, reference images would be stored in a buffer
which size was not determined by the actual size of the area in pixels
which was available for the QPainter, but that size scaled down by
devicePixelRatioF(). Hence on high resolution displays all
reference images would look blurry and low-res.

This commit fixes this behaviour by introducing high-res buffer
and making sure that it takes the reference image from the mipmap
which size is the closest to the actual new size instead of the
one that is scaled down because of the UI scaling
(devicePixelRatioF()).

I also changed the way the pixel art images (or any images that are being enlarged)
are drawn: now they use FastTransformation instead of SmoothTransformation.

M  +6    -2    libs/brush/kis_qimage_pyramid.cpp
M  +1    -1    libs/brush/kis_qimage_pyramid.h
M  +14   -3    libs/ui/KisReferenceImage.cpp
M  +9    -3    libs/ui/KisReferenceImagesDecoration.cpp

https://invent.kde.org/graphics/krita/commit/1d8b94e3c545b5d2ac98242dd14c6c0becb17071
Comment 8 Halla Rempt 2020-11-04 08:43:57 UTC
Git commit d61854206d985ecfa6530537fdb1f010e0b22bb0 by Boudewijn Rempt, on behalf of Agata Cacko.
Committed on 04/11/2020 at 08:23.
Pushed by rempt into branch 'krita/4.3'.

Draw reference images in high res on 4k display

Before this commit, reference images would be stored in a buffer
which size was not determined by the actual size of the area in pixels
which was available for the QPainter, but that size scaled down by
devicePixelRatioF(). Hence on high resolution displays all
reference images would look blurry and low-res.

This commit fixes this behaviour by introducing high-res buffer
and making sure that it takes the reference image from the mipmap
which size is the closest to the actual new size instead of the
one that is scaled down because of the UI scaling
(devicePixelRatioF()).

I also changed the way the pixel art images (or any images that are being enlarged)
are drawn: now they use FastTransformation instead of SmoothTransformation.
(cherry picked from commit 1d8b94e3c545b5d2ac98242dd14c6c0becb17071)

M  +6    -2    libs/brush/kis_qimage_pyramid.cpp
M  +1    -1    libs/brush/kis_qimage_pyramid.h
M  +14   -3    libs/ui/KisReferenceImage.cpp
M  +9    -3    libs/ui/KisReferenceImagesDecoration.cpp

https://invent.kde.org/graphics/krita/commit/d61854206d985ecfa6530537fdb1f010e0b22bb0
Comment 9 Halla Rempt 2020-11-04 08:44:05 UTC
Git commit d4556045bed9c340a73a9a7d8b8c254e353a3584 by Boudewijn Rempt, on behalf of Agata Cacko.
Committed on 04/11/2020 at 08:23.
Pushed by rempt into branch 'krita/4.3'.

Remove the workaround border from the ref images

Before this commit, Reference Images would use the same workaround
as the brush tips since they all use KisQImagePyramid.
However it is not needed for Reference Images and creates
an empty margin around the images.

This commit adds a new method to KisQImagePyramid to get the image
without the workaround border.
(The workaround is just 1 pixel of transparency around the whole edge
that KisQImagePyramid is returning as the closest mipmap image).
(cherry picked from commit fb247f6a6d87a3faf90f75a00a91d4be1335978c)

M  +9    -0    libs/brush/kis_qimage_pyramid.cpp
M  +2    -0    libs/brush/kis_qimage_pyramid.h
M  +1    -1    libs/ui/KisReferenceImage.cpp

https://invent.kde.org/graphics/krita/commit/d4556045bed9c340a73a9a7d8b8c254e353a3584