Render image widgets correctly on HiDPI displays when the display's window scale is not equal to 1. #1239
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes #761.
This fix applies to high resolution displays (or any display where the user has set the display scale to something other than 100%). For example, imagine you want to render a 16x16 image (in yuck:
:image-height 16 :image-width 16
) at 2x scale. The resulting image will be 32x32 physical pixels on the display. If your image source has the fidelity (e.g. you have a >32x32 pixel PNG or an SVG), the resulting image should be sharp, but previously, it was being rendered at the logical resolution (16x16) and upscaled to the physical resolution, creating a blurry image.Usage
No configuration changes. Images will simply be rendered at high resolution if possible.
Showcase
Before and after:
Additional Notes
All of the practical code is taken from src/widgets/systray.rs. Thank you to whoever wrote that code! Also, I am relatively new to Rust, any comments on style etc. are welcome.
Checklist
Please make sure you can check all the boxes that apply to this PR.
docs/content/main
directory has been adjusted to reflect my changes.cargo fmt
to automatically format all code before committing