artemsen / swayimg

Image viewer for Wayland
MIT License
380 stars 31 forks source link

Scaling artefacts #89

Closed smlx closed 1 year ago

smlx commented 1 year ago

I'm seeing an issue where images are displayed with scaling artefacts. To show what I mean, here are some screenshots. This image is larger than my screen size, so it is scaled down via -s fit. Notice the extra pixelation in the second image:

Good: good

Bad: bad

My display has a scale factor of 2:

$ swaymsg -t get_outputs | grep scale
    "scale": 2.0,
    "scale_filter": "nearest",

The most recent good commit is 7959505e56202fc495038dab3fe857320f97dd5d, and the first bad commit I can confirm is v1.11. The commits in between don't execute for me with this runtime error:

wl_shm@4: error 1: invalid size (0)

I wonder if this has something to do with the anti-aliasing feature, as this was introduced in the next few commits after 7959505e56202fc495038dab3fe857320f97dd5d.

artemsen commented 1 year ago

Fixed, thank you for the bug report!

smlx commented 1 year ago

Confirmed, thanks for the quick fix :tada:

nekopsykose commented 1 year ago

this still seems to be the case for either -s fit or -s optimal (default) and is somewhat easiest to see for images bigger than the current display with 1 scale (no sway scaling modifier), e.g. a screenshot of text from mobile (>1440 px tall) on my 1440p display, which then looks somewhat garbled (screenshot of how it gets rendered):

by contrast, opening the same image in firefox to view it it looks normal:

(make sure to open the original images so they are displayed without githubs scaling in markdown because that makes them both look weird as it further upscales them here)

to be clear, they look like that with and without this commit, so maybe this is a separate issue. images that aren't larger than the monitor (don't have to be scaled down for display) render the text perfectly okay; but firefox scales it down without any bad aliasing unlike swayimg.

if you want to reproduce it yourself, it's probably easiest to generate a very big canvas and fill it with text in gimp or something and compare the display of the exported .png in swayimg to other viewers

artemsen commented 1 year ago

Looks like it relates to #49. The current implementation of scale is really dumb.

nekopsykose commented 1 year ago

could be. though the actual a antialias toggle is a separate thing, i guess the scaling in general here is similar

hhartzer commented 10 months ago

I'm getting some pretty weird scaling behaviors in v2.0. Should I provide some examples?

Thank you!

artemsen commented 10 months ago

Should I provide some examples?

Yes, please. I would appreciate if you create new issue instead of using this one.