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

Render image widgets correctly on HiDPI displays when the display's window scale is not equal to 1. #1239

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

zane-weissman
Copy link

@zane-weissman zane-weissman commented Dec 1, 2024

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:
Screenshot from 2024-12-01 13-48-26 Screenshot from 2024-12-01 13-54-54

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.

  • All widgets I've added are correctly documented.
  • I added my changes to CHANGELOG.md, if appropriate.
  • The documentation in the docs/content/main directory has been adjusted to reflect my changes.
  • I used cargo fmt to automatically format all code before committing

@zane-weissman zane-weissman marked this pull request as ready for review December 1, 2024 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Better image scaling with SVG (on Wayland)
1 participant