Skip to content

Conversation

@eirikbakke
Copy link
Contributor

@eirikbakke eirikbakke commented Mar 11, 2025

Here are a few more changes to ensure that SVG icons render at full resolution on HiDPI screens.

This PR handles the transformation from
Graphics.drawImage(ImageIcon, x, y, null)
to
Icon.paintIcon(null, Graphics, x, y)
at various places in the codebase.

This fixes e.g. poor-resolution lightbulb icons in the editor gutter on Windows at fractional HiDPI scale factors. See the before/after screenshot below, which was taken on Windows 11 with the 150% HiDPI scaling level.

image

All simple such cases were found by grepping for "drawImage" and reviewing each case. Test classes and NBI related classes were skipped.

This is mostly an improvement for screens with a fractional HiDPI scaling (e.g. 150%) on Windows. On 200% scaling (including on MacOS), icons are drawn properly even with drawImage, due to ImageUtilities returning MultiResolutionImage instances nowadays with 1x and 2x resolutions present. The latter is still a good fallback for cases that may not yet be covered otherwise.

@eirikbakke eirikbakke added Platform [ci] enable platform tests (platform/*) UI User Interface labels Mar 11, 2025
@eirikbakke eirikbakke force-pushed the pr-gutterscale branch 2 times, most recently from 691107c to 2f150ee Compare March 11, 2025 13:42
…resolution.

Various SVG icons were previously shown in a lower resolution due to being painted with Graphics.drawImage(ImageIcon, x, y, null) instead of Icon.paintIcon(null, Graphics, x, y). This PR changes the former to the latter in all the simple cases that were found throughout the codebase (by grepping for 'drawImage' and manually reviewing each case).

For example, the lightbulb icons in the editor gutter, and the actions in the menu that shows up when you click them, were shown in low resolution on Windows 11 with 150% HiDPI scaling enabled.

This is mostly an improvement for screens with a fractional HiDPI scaling (e.g. 150%) on Windows. On 200% scaling (including on MacOS), icons are drawn properly even with drawImage, due to ImageUtilities returning MultiResolutionImage instances nowadays with 1x and 2x resolutions present.
@mbien mbien added this to the NB26 milestone Mar 11, 2025
Copy link
Member

@mbien mbien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code looks good to me

@eirikbakke
Copy link
Contributor Author

Thanks for the quick review! Will merge.

@eirikbakke eirikbakke merged commit 6fcd2c0 into apache:master Mar 12, 2025
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Platform [ci] enable platform tests (platform/*) UI User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants