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

[FEATURE] Better image scaling with SVG (on Wayland) #761

Open
davidheiss opened this issue Apr 30, 2023 · 2 comments · May be fixed by #1239
Open

[FEATURE] Better image scaling with SVG (on Wayland) #761

davidheiss opened this issue Apr 30, 2023 · 2 comments · May be fixed by #1239
Labels
enhancement New feature or request

Comments

@davidheiss
Copy link

Description of the requested feature

As for now, when I use the image widget with an SVG and an integer scaling on Wayland of 2, they appear blurry. That's probably the case because the Scalable vector graphic is scaled up the same way as any other raster-based image (JPEG, PNG, etc.). The feature I had in mind is to implement a scaling method for any vector-based image without loosing on quality.

Proposed configuration syntax

It could automatically be detected or explicit stated.

(image :path "icon.svg" :vector true)

Additional context

I use Hyprland with Wayland and an integer scaling of 2 on a 2880×1440 monitor with HiDPI.

@davidheiss davidheiss added the enhancement New feature or request label Apr 30, 2023
@zane-weissman
Copy link

I think I found the solution in these two posts, and it applies to raster images as well as SVGs: 1. 2.

When an SVG is read as an image, it's read into a GTK "pixbuf" which is always raster (it's basically just an array of pixels). In theory would be fine - just write more pixels into the pixbuf. However, a pixbuf is always rendered in logical pixels rather than display pixels, so this would scale it up too big (and still be blurry).

The solution is to fill the pixbuf at 2x scale (or whatever the scale should be), and then convert it to a cairo surface, which supports rendering at integer scales. Then the final image can be set from the cairo surface.

I'm going to play around with this soon, it should be relatively straightforward to implement.

@davidheiss
Copy link
Author

I came across the librsvg library, which appears to serve a similar purpose to ours—rendering SVG icons on the desktop. Although I haven't used GNOME in a while, I don’t recall it having issues with blurry icons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants