drawAtlas with alpha_8 image.

28 views
Skip to first unread message

craste...@gmail.com

unread,
Jun 9, 2025, 11:14:07 PM6/9/25
to skia-discuss
When drawing an alpha_8 image with the normal drawImage() call, the black pixels are treated as transparent and the white pixels are opaque.

But when drawing the SkImage using drawAtlas, the black pixels are opaque white.

Is there a way to change this behavior?

Michael Ludwig

unread,
Jun 10, 2025, 9:22:10 AM6/10/25
to skia-discuss
What blend mode are you passing into drawAtlas?  drawImage and drawImageRect have somewhat specialized handling for alpha-only images where they do not actually replace the SkShader on the paint and will modulate the A8 per-pixel alpha with whatever the shader produces (or the paint's solid color).  drawAtlas always replaces the shader of the paint with an SkShader derived from the provided atlas image.  Its colorization for an A8 atlas image is dependent on the blend mode that combines with the per-entry colors.

craste...@gmail.com

unread,
Jun 10, 2025, 9:51:41 AM6/10/25
to skia-discuss
Just SrcOver

craste...@gmail.com

unread,
Jun 10, 2025, 6:39:06 PM6/10/25
to skia-discuss
Solution:  set the sprite colors to SK_ColorTRANSPARENT.
Put the color of the sprite into the paint that is passed in and the alpha image will use that.

On Tuesday, June 10, 2025 at 6:22:10 AM UTC-7 michae...@google.com wrote:
Reply all
Reply to author
Forward
0 new messages