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

Colours are not correctly calculated when alpha is low #909

Closed
andydotxyz opened this issue Apr 27, 2020 · 4 comments
Closed

Colours are not correctly calculated when alpha is low #909

andydotxyz opened this issue Apr 27, 2020 · 4 comments
Labels
question A question has been asked

Comments

@andydotxyz
Copy link
Member

It looks like there is a mismatch with pre-mul vs regular alpha handling.

I would propose that we should hide any GL requirement to be pre-multiplied so the API works more like the HTML RGB handling which I think is more common.

Sadly making this change (one way or the other) will likely break some people's app colouring if they have picked bespoke colour values where Alpha < R or G or B.

@andydotxyz
Copy link
Member Author

Fixing this is better sooner than later, but it could be considered a breaking change (as some developers may see their colours get much more faded when this happens... so should it wait until later? discussion in #fyne-contributors

@andydotxyz
Copy link
Member Author

There may not be an issue here... reading the docs more carefuly I see:

RGBA represents a traditional 32-bit alpha-premultiplied color, having 8 bits for each of red, green, blue and alpha.

And really if we want to have non-pre-multiplied in our code we should use NRGBA

NRGBA represents a non-alpha-premultiplied 32-bit color.

That would behave like HTML colour code notation...

@andydotxyz andydotxyz added question A question has been asked and removed bug Something isn't working labels May 6, 2020
@andydotxyz
Copy link
Member Author

Yes, this is not a public API problem - but our code could be tidied up to use NRGBA everywhere except in the Gl based renderer code (as there premul is expected).

Everywhere we used image.Image or color.Color we are OK :)

andydotxyz added a commit to andydotxyz/fyne that referenced this issue May 6, 2020
…e-multiplied.

This changed some of the test images, I guess that the alpha channel differences affected their represntation.
Also update the image comparison to check the bytes as the RGBA vs NRGBA colour models was breaking things
but PNG is always NRGBA, so something strange with the decoder there.

Fixes fyne-io#909
andydotxyz added a commit to andydotxyz/fyne that referenced this issue May 6, 2020
…e-multiplied.

This changed some of the test images, I guess that the alpha channel differences affected their represntation.
Also update the image comparison to check the bytes as the RGBA vs NRGBA colour models was breaking things
but PNG is always NRGBA, so something strange with the decoder there.

Fixes fyne-io#909
andydotxyz added a commit that referenced this issue May 6, 2020
…e-multiplied.

This changed some of the test images, I guess that the alpha channel differences affected their represntation.
Also update the image comparison to check the bytes as the RGBA vs NRGBA colour models was breaking things
but PNG is always NRGBA, so something strange with the decoder there.

Fixes #909
@andydotxyz
Copy link
Member Author

On develop for testing.
Lots of testing :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A question has been asked
Projects
None yet
Development

No branches or pull requests

1 participant