/ Published in: ActionScript 3
This inverts the transparency on a Bitmap (probably supplied a PNG source) that specifically has two colors in it; "#656565" and "transparent" - you can tweak the threshold lines specifically if you'd like to modify that to use a range, or whatever.
Adapted from http://stackoverflow.com/questions/608087/flex-actionscript-white-to-transparent and http://www.sephiroth.it/tutorials/flashPHP/thresold/
Adapted from http://stackoverflow.com/questions/608087/flex-actionscript-white-to-transparent and http://www.sephiroth.it/tutorials/flashPHP/thresold/
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
private function invert(oldBmp:Bitmap):Bitmap { var source:BitmapData = oldBmp.bitmapData; var destin:BitmapData = source; var rectan:Rectangle = new Rectangle(0, 0, source.width, source.height); // Replace all transparent pixels with a solid color destin.threshold(source, rectan, new Point(), "==", 0x00000000,0xFFFF0000); // Replace all the pixels greater than 0xf1f1f1 by transparent pixels destin.threshold(source, rectan, new Point(), "==", 0xff656565,0x0000FF00); return new Bitmap(destin); }