Applying Color Transformations : BitmapData : Graphics Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Graphics » BitmapData »

 

Applying Color Transformations


 
package {

    import flash.net.URLRequest;
    import flash.display.BitmapData;
    import flash.display.Bitmap;
    import flash.display.Sprite;
    import flash.display.Loader;
    import flash.geom.Rectangle;
    import flash.events.Event;
    import flash.geom.ColorTransform;

    public class Main extends Sprite {

        private var _loader:Loader = new Loader();

        public function Main () {
            _loader.load(new URLRequest("http://www.navioo.com/samplefiles/image2.jpg"));
            _loader.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);
        }

        private function completeHandler(event:Event):void {
            var w:Number = _loader.width;
            var h:Number = _loader.height;

            var bitmapData:BitmapData = new BitmapData(w, h);
            bitmapData.draw(_loader);
            bitmapData.colorTransform(new Rectangle(00, w/2, h/2)new ColorTransform(10010000));
            bitmapData.colorTransform(new Rectangle(w/20, w/2, h/2)new ColorTransform(01010000));
            bitmapData.colorTransform(new Rectangle(0, h/2, w/2, h/2)new ColorTransform(00110000));
            bitmapData.colorTransform(new Rectangle(w/2, h/2, w/2, h/2)new ColorTransform(11010000));

            var bitmap:Bitmap = new Bitmap(bitmapData);
            addChild(bitmap);
        }
    }
}
 

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Graphics
» BitmapData