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

Alpha blending bug #13

Open
JasonMDavey opened this issue Oct 22, 2022 · 0 comments
Open

Alpha blending bug #13

JasonMDavey opened this issue Oct 22, 2022 · 0 comments

Comments

@JasonMDavey
Copy link

JasonMDavey commented Oct 22, 2022

It appears the bug from "Programming in C in 2022" is still present.

This is because when blending colours you use the alpha value of the "incoming" colour to calculate the new blended RGB colour components for the pixel, but the alpha component of the pixel is never updated.

So if the canvas initially starts filled with zeroes, then each pixel will always have alpha 0. And blended colour writes will never modify this. So the final exported image will have the correct R/G/B values, but always have alpha 0 in every pixel.

You probably want to "accumulate" the alpha from both the current colour on the canvas, and the "incoming" colour. For example, if the canvas contains a pixel with 25% alpha, and you draw a pixel with 50% alpha on top, the resulting alpha should be greater than 25%. But the current code will never modify it.

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

No branches or pull requests

1 participant