Question

I have two layers of bitmaps:
1st - some random image
2nd - bitmap filled with black color that covers 1st bitmap
Also I have a mask bitmap. I trying to make something like this
https://dl.dropbox.com/u/13089585/so/001.jpg
But I get something like this:
https://dl.dropbox.com/u/13089585/so/002.jpg
I tryed to do this using BitmapData::copyPixels, BitmapData::copyChannel and BitmapData::draw with different combinations of parameters, but still can not make it... I need some method that will override alpha value on dest. bitmap, but only if this value is greater then in src. bitmap.

Was it helpful?

Solution

first off, if you use a sprite instead of a bitmap as a mask, you can use BitmapData.draw() with BlendMode.ERASE to get that effect. but that will not work if you want translucency (e.g. 50% alpha).

what you can do is have the mask bitmap be black where you want the 2nd image to be transparent and and transparent elsewhere (30% alpha in the mask will become 70% alpha on 2nd bitmap). now, create a 3rd BitmapData with fill color red, draw the mask onto 3rd BitmapData using BlendMode.DARKEN. then, use copyChannel() from 3rd red to 2nd alpha.

it's not pretty, but real life never is...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top