Skip to content

Update bitmap SKAlphaType in SKXamlCanvas.Wasm.cs - #2443

Merged
mattleibow merged 2 commits into
mono:mainfrom
roubachof:main
Jun 14, 2023
Merged

Update bitmap SKAlphaType in SKXamlCanvas.Wasm.cs#2443
mattleibow merged 2 commits into
mono:mainfrom
roubachof:main

Conversation

@roubachof

@roubachof roubachof commented Apr 18, 2023

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

roubachof commented Jun 13, 2023

Copy link
Copy Markdown
Contributor Author

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