Black edges observed around the circular shape when Image is resized

164 views
Skip to first unread message

vulapu yashwanth

unread,
Apr 16, 2024, 1:29:38 PMApr 16
to skia-discuss

An input image is added as a vector of bytes and resized to a larger size compared to original size with SkFilterMode::kLinear mode. Issue is black color artifacts are observed around the resized image.

Any inputs are appreciated. Thanks.

Brian Osman

unread,
Apr 16, 2024, 1:35:49 PMApr 16
to skia-d...@googlegroups.com
This is because the image is represented with unpremultiplied alpha. Texture filtering of an unrepmul image generates these kinds of artifacts (because the black from the transparent region is blended with the actual color in the opaque region). The solution is to use premultiplied alpha - you can do that by explicitly decoding to premultiplied alpha: https://fiddle.skia.org/c/f93f32efafb6118565973a0bad7876e4

There are many articles online about this effect, here's one older one that's pretty thorough: https://www.realtimerendering.com/blog/gpus-prefer-premultiplication/

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/5bd6635c-b5ad-4510-b1a0-9b8dfc9394fdn%40googlegroups.com.

vulapu yashwanth

unread,
Apr 17, 2024, 10:35:14 PMApr 17
to skia-discuss
Thank you Brian for the quick response. I didn't observe the same issue on skia-m97 version but it is observed on the latest versions of skia. Is there any change in skia related to this ?

Brian Osman

unread,
Apr 18, 2024, 7:43:47 AMApr 18
to skia-d...@googlegroups.com
Yes, I don't remember exactly when m97 came out, but at some point in the past, Skia would ALWAYS convert images to premultiplied alpha before using them. Although that's better for this one particular case, there are some specific situations where you really do want to leave an image unpremultiplied. For that reason, we changed the behavior (several years ago?) so that the codecs would not automatically provide premultiplied data.

Reply all
Reply to author
Forward
0 new messages