BitmapData masking: how to merge 2 alpha channels?
Copy link to clipboard
Copied
How can I apply an alpha mask from one bitmapdata to another? In other words, I want to merge the alphas, not simply copy one alpha channel to another bitmap.
Here's an illustration:
Notice that both the triangle and the ellipse have alpha channels, and the result is an intersection of these alpha channels. The RGB channels from the second image are used, and discarded from the first.
I've looked into using BitmapData/merge(), draw(), copyChannel(), but they don't seem to do what I want. Anyone?
Cheers.
-Aaron
Copy link to clipboard
Copied
Aha, looks like the answer was right under my nose: copyPixels() can do exactly this:
If you include the alphaBitmap and alphaPoint parameters, you can use a secondary image as an alpha source for the source image. If the source image has alpha data, both sets of alpha data are used to composite pixels from the source image to the destination image. ThealphaPoint parameter is the point in the alpha image that corresponds to the upper-left corner of the source rectangle. Any pixels outside the intersection of the source image and alpha image are not copied to the destination image.
Cheers.
-Aaron

