Skip to content

Fix alpha bleeding when smooth-scaling images#10528

Open
tronical wants to merge 1 commit intomasterfrom
simon/image-smooth-scale-with-alpha
Open

Fix alpha bleeding when smooth-scaling images#10528
tronical wants to merge 1 commit intomasterfrom
simon/image-smooth-scale-with-alpha

Conversation

@tronical
Copy link
Member

After loading for example PNGs with an alpha, prefer passing it to renderers as pre-multiplied alpha, so that nearby transparent pixels (r=g=b=a=0) don't contribute anything as pre-multiplication will zero out their r/g/b.

Fixes #10469

@tronical tronical requested a review from ogoffart January 23, 2026 14:12
Copy link
Member

@ogoffart ogoffart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Premultiplied is probably the right format to store the cached rendered image. But while this works for image loaded from file, it would still be a problem for image created by the user with the ARGB (not premultiplied) format.

@tronical
Copy link
Member Author

Premultiplied is probably the right format to store the cached rendered image. But while this works for image loaded from file, it would still be a problem for image created by the user with the ARGB (not premultiplied) format.

Yeah, I was thinking the same. But at least there folks have a choice :)

@tronical tronical force-pushed the simon/image-smooth-scale-with-alpha branch 2 times, most recently from ec6a7fd to a8ab43b Compare January 23, 2026 15:01
@ogoffart
Copy link
Member

Could we have a screenshot test with an image that highlights the wrong behavior?

@tronical
Copy link
Member Author

Could we have a screenshot test with an image that highlights the wrong behavior?

That turns out to be rather difficult, given that already the smooth scaling with pre-multiplied alpha seems to result in differences with skia :-(

@tronical tronical force-pushed the simon/image-smooth-scale-with-alpha branch from a8ab43b to 48ca77f Compare January 23, 2026 16:24
@tronical
Copy link
Member Author

I'm trying a new PR that disables the smooth scaling for these tests - which also sucks :-(

@ogoffart
Copy link
Member

smooth scaling with pre-multiplied alpha seems to result in differences with skia :-(

Ah oops. This might be why some test were skipped before:

// Skia doesn't have identical rendering across platforms
//ignore:skia

(and more tests have that)

We could of course skip more tests but that'd be unfortunate. Or have different threshold for skia.

@ogoffart
Copy link
Member

I'm trying a new PR that disables the smooth scaling for these tests - which also sucks :-(

Ah good idea.

@tronical tronical force-pushed the simon/image-smooth-scale-with-alpha branch 2 times, most recently from a0d1aa5 to 034951b Compare January 27, 2026 12:16
After loading for example PNGs with an alpha, prefer passing it to
renderers as pre-multiplied alpha, so that nearby transparent pixels
(r=g=b=a=0) don't contribute anything as pre-multiplication will zero
out their r/g/b.

Fixes #10469

For the screenshot tests, smooth scaling is disabled because it results
in different rendering between macOS and Linux on Skia with
pre-multiplied alpha.
@tronical tronical force-pushed the simon/image-smooth-scale-with-alpha branch from 034951b to 36b83e7 Compare January 27, 2026 13:05
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.

Smooth image rendering, adds strange white border to partially transparent image parts

2 participants