Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icons of Text are not scaled #80

Open
akoch-yatta opened this issue Jun 25, 2024 · 2 comments
Open

Icons of Text are not scaled #80

akoch-yatta opened this issue Jun 25, 2024 · 2 comments
Labels
Bug A Derivation of Expected Behavior HiDPI A HiDPI-Related Issue or Feature SWT Issue for SWT

Comments

@akoch-yatta
Copy link

The icons (IDI_SEARCH, IDI_CANCEL, ...) are not scaled on dpi change, e.g. visible in the Error Log or the Preferences Dialog

Image

Image

@akoch-yatta akoch-yatta converted this from a draft issue Jun 25, 2024
@akoch-yatta akoch-yatta added SWT Issue for SWT Bug A Derivation of Expected Behavior HiDPI A HiDPI-Related Issue or Feature labels Jun 25, 2024
@amartya4256
Copy link

The issue is with how the icon is loaded and drawn. The method addIcons loads the icon using OS.LoadIconMetric (OS.GetLibraryHandle (), searchIconResource, 1, phicon). Here there is no reference provided to what size the image is going to be loaded for neither does the OS know for what monitor it is loaded. I tested this with my primary monitor set to 200 and 100 and for both I get the icon of different sizes, 28x28 and 20x20 respectively. So, one thing is for certain that this method loads the icon accordign to the primary monitor zoom level. Refer: https://learn.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-loadiconmetric

Now this icon is later on drawn in the method WM_DRAWITEM. The drawing call is like this: OS.DrawIconEx (struct.hDC, 0, y, hIcon, side, side, 0, 0, OS.DI_NORMAL);
The documentation says, with this call, it will draw the image in the size in which it was loaded (default). So, that's why there is no scaling. Refer: https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-drawiconex

However, I have implemented a fix for this and that has a little to do with how the icon is loaded since it is independent of what window it is going to be drawn on. Rather, when we are drawing it, we should calculate the bounds of the image and scale it up.

Here's how it looks when the image is scaled down from 200 to 100:

Image

Similarly, here's the snip for 100 to 200:

Image

@amartya4256
Copy link

Although I see a little bit of sharpness on the edge in the image when it is drawn with a higher Zoom.

@amartya4256 amartya4256 self-assigned this Jul 2, 2024
@amartya4256 amartya4256 moved this from 🔖 Ready: Atomic to 👀 In Review in HiDPI Jul 2, 2024
@amartya4256 amartya4256 moved this from 👀 In Review to ✅ Done in HiDPI Jul 15, 2024
@amartya4256 amartya4256 removed their assignment Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A Derivation of Expected Behavior HiDPI A HiDPI-Related Issue or Feature SWT Issue for SWT
Projects
Status: Done
Development

No branches or pull requests

2 participants