Skip to content

Alpha blending bug #13

Open
Open
@JasonMDavey

Description

@JasonMDavey

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions