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

.svg are poorly rendered #72

Open
jlo62 opened this issue May 17, 2024 · 3 comments
Open

.svg are poorly rendered #72

jlo62 opened this issue May 17, 2024 · 3 comments

Comments

@jlo62
Copy link

jlo62 commented May 17, 2024

Hi, the gradients in svg files are rendered poorly.
A workaround is to render them as png, but then it's size increases drastically (e.g. 10kb to 1.4mb (for 2.2K) or 2.1mb (for 4k) ), and it isn't really editable, so I have to keep the old (svg) copy around.

tip: The closer in you zoom, the worse you can see the difference.

Wallpaper with svg:
image

same image, but rendered out as png in inkscape:
bg

the source file (firefox/github(?) also renders it poorly, but not that bad):
bg

@mstoeckl
Copy link
Collaborator

mstoeckl commented May 17, 2024

This issue is known as color banding, and there are two main approaches to solving it: using dithering on the image (which Inkscape currently when it renders a PNG), or displaying the image at higher bit depth (which, to avoid banding either requires a monitor which supports it, or for Sway to do the dithering itself.)

Implementing either option inside Swaybg would require specific SVG processing that the current image loader, GdkPixbuf, does not support. See #60 for another issue that would be solved with a special SVG pathway.

@jlo62
Copy link
Author

jlo62 commented May 17, 2024

Is this like mixing pixels from one of the color and the other color to make a gradient in a gradient?

So we would need a whole new svg renderer (or a library)?

@mstoeckl
Copy link
Collaborator

Is this like mixing pixels from one of the color and the other color to make a gradient in a gradient?

Yes, see https://en.wikipedia.org/wiki/Dither .

So we would need a whole new svg renderer (or a library)?

swaybg would need to explicitly use librsvg; there's an experimental branch mentioned in #60 , mstoeckl/svg-direct which does this, and enabling dithering on top of that would not be too much work. Technically, it isn't a new renderer, because I believe GdkPixbuf uses librsvg itself anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants