Can I apply an image mask to a transparent image?

Can I add a mask to an image and have the resulting image retain the transparency from the original image (as well as cropping it to the mask). When I do setMaskImage it seems to toss out the transparency from the original PNG and use only the mask.

Here's an illustration of what I'm trying to achieve:

I haven't used setMaskImage, but it sounds to me like it's intended to set the alpha—replacing the images's previous alpha mask?

What I HAVE used should do what you want: setStencilImage() (used before drawing, like you would a draw mode).

If you want to create an image combining the two "masks" you could draw into a new image.

Thanks. Stencil is what I wanted. I saw that in the docs, but the illustration in the linked wiki article made me think it was more of an inverted drawing mode or something. The article itself didn't help clarify...

1 Like