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

Update bitmap SKAlphaType in SKXamlCanvas.Wasm.cs #2443

Merged
merged 2 commits into from
Jun 14, 2023
Merged

Conversation

roubachof
Copy link
Contributor

@roubachof roubachof commented Apr 18, 2023

To obtain the expected built bitmap by skia, we need to change the SKAlphaType of the build image. Opaque doesn't give correct results when bluring colors with alpha for example. Premul doesn't work either for a particular reason: In javascript we use the ImageData API.
The ImageData API store the pixels as un-premultiplied. So if we use the premultiplied enum value we end up with wrong pixel colors (same result as Opaque in fact). I tested unpremul value in a project that is using blur, and it gives the correct results.

roubachof and others added 2 commits April 18, 2023 12:11
To obtain the expected built bitmap by skia, we need to change the SKAlphaType of the build image.
Opaque doesn't give correct results when bluring none opaque colors for example.
Premul doesn't work either for a particular reason:
In javascript we use the ImageData API.
The ImageData API store the pixels as un-premultiplied.
So if we use the premultiplied enum value we end up with wrong pixel colors (same result as Opaque in fact).
I tested unpremul value in a project that is using blur, and it gives the correct results.
@mattleibow
Copy link
Contributor

@roubachof is there a way to create a test? Right now we have no way to capture the image, but some drawing code that I can run against this PR to test?

Is it just a batter of drawing two different blocks, or is it blending with other elements?

@roubachof
Copy link
Contributor Author

roubachof commented Jun 13, 2023

When this PR will be merged (very soon I hope :) You will be able to test it with the WASM target of the Uno toolkit sample => Control => ShadowContainer
You should see this :
shadows-neumorphism
If it's in premul, the shadows will look "dirty"

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