Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

BitmapData masking: how to merge 2 alpha channels?

Engaged ,
Nov 08, 2013 Nov 08, 2013

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:

merge-alpha.fw.png

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

TOPICS
ActionScript
586
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 08, 2013 Nov 08, 2013
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines