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

Make blending (in scaling) respect alpha #227

Merged
merged 1 commit into from
Nov 29, 2024

Conversation

abewieland
Copy link
Contributor

When sampling from multiple pixels to implement scaling (only relevant for anti-aliasing), the sampled values should be multiplied by their alpha value to prevent colors "bleeding" from almost-transparent regions. Consider this image, which consists of a square in the center with color #00ff00ff and a border of #ff000001:
alpha_blend

Without multiplying by the alpha, we can get unexpected red in the border region, as seen here with anti-aliasing on (so bicubic):
20241129_14h33m21s_grim
This is because the alpha values are higher there from the green square, but the red component is stronger than it should be.

With the PR gives:
20241129_14h31m30s_grim

Copy link
Owner

@artemsen artemsen left a comment

Choose a reason for hiding this comment

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

I didn't even think that someone would fix this part of the code.
Thanks!

src/pixmap.c Outdated Show resolved Hide resolved
src/pixmap.c Outdated Show resolved Hide resolved
@artemsen artemsen merged commit e8f421b into artemsen:master Nov 29, 2024
5 checks passed
@abewieland abewieland deleted the bleeding branch November 29, 2024 15:52
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.

2 participants