Thanks, so is there a way for me to ignore transparent pixels in a png for mouseEvents which is the problem I was trying to solve here? This is for a HTML5 target.
Thanks, I am going to use bitmapData.getPixel32(x,y) which will solved this problem very nicely. If the value returned is 0 then I know that the pixel is transparent and do nothing.
var maskData:BitmapData = file.data;
var _mask:Bitmap = new Bitmap(maskData);
addChild(_mask);
var shapeData:BitmapData = new BitmapData(maskData.width, maskData.height, true, 0xFF0000FF);
var rect:Rectangle = new Rectangle(0, 0, maskData.width, maskData.height);
shapeData.copyChannel(maskData, rect, new Point(), BitmapDataChannel.ALPHA, BitmapDataChannel.ALPHA);
_shape = new Bitmap(shapeData);
addChild(_shape);
It copies everything at once, and it only touches the channel you care about, which ought to make it faster. But if your implementation is already fast enough, then I guess you don’t have to worry about it.
I am not using trying to use a mask anymore. I am using getColorBoundsRect() and cropping the bitmapData to the area that contains no transparent pixels. Then I am using transform.colorTransform to change the color.
We do not have colorTransform support across the board – I’m hoping (?) there’s some fast way to do color transformation when blitting with Cairo and Canvas, but to my knowledge, there is one. We need a strategy for how we will handle that.
In the meantime, bitmapData.colorTransform should work fine, so if you have a bitmap already, or bitmapData.draw to one, you should be able to accomplish what you need