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.java2java.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(0, 0, w/2, h/2), new ColorTransform(1, 0, 0, 1, 0, 0, 0, 0));
bitmapData.colorTransform(new Rectangle(w/2, 0, w/2, h/2), new ColorTransform(0, 1, 0, 1, 0, 0, 0, 0));
bitmapData.colorTransform(new Rectangle(0, h/2, w/2, h/2), new ColorTransform(0, 0, 1, 1, 0, 0, 0, 0));
bitmapData.colorTransform(new Rectangle(w/2, h/2, w/2, h/2), new ColorTransform(1, 1, 0, 1, 0, 0, 0, 0));
var bitmap:Bitmap = new Bitmap(bitmapData);
addChild(bitmap);
}
}
}
|