flash on 2013-2-14
package {
import flash.display.*;
import flash.filters.*;
import flash.geom.*;
import flash.system.*;
import flash.net.*;
public class FlashTest extends Sprite {
public function FlashTest() {
// just testing, never mind..
var loader:Loader = new Loader;
loader.contentLoaderInfo.addEventListener("complete", ready);
loader.load (new URLRequest ("http://assets.wonderfl.net/images/related_images/a/a1/a129/a129c022a95edf9d0eeccfd0e0b709d905264415"), new LoaderContext(true));
}
public function ready (e:Object):void {
var bd1:BitmapData = new BitmapData (200, 200);
bd1.draw (e.target.content.bitmapData, new Matrix (4,0,0,4,-80,-100), null, null, null, true);
addChild (new Bitmap (bd1));
var bd2:BitmapData = bd1.clone();
bd2.applyFilter (bd2, bd2.rect, new Point, new BlurFilter (2,2, 3));
bd2.lock();
for (var i:int = 0; i < 200; i++)
for (var j:int = 0; j < 200; j++) {
var c:uint = bd2.getPixel(i, j);
var r:uint = (c & 0xFF0000) >> 16;
var g:uint = (c & 0xFF00) >> 8;
var b:uint = c & 255;
var s:Number = ((r & 0xc0) + (g & 0xc0) + (b & 0xc0))/(r+g+b);
r *= s; g *= s; b *= s;
c = (r << 16) | (g << 8) | b;
bd2.setPixel (i,j,c);
}
bd2.unlock();
addChild (new Bitmap (bd2)).y = 200;
}
}
}