In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: かゆうま

写真の中の人ををゾンビっぽくします。

写真:	Business meeting
http://www.flickr.com/photos/llawliet/2547595587/
Uploaded on June 3, 2008 by llawliet
http://creativecommons.org/licenses/by/3.0/deed.ja
Get Adobe Flash player
by yoneken 13 May 2009
/**
 * Copyright yoneken ( http://wonderfl.net/user/yoneken )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/qcNt
 */

// forked from osamX's かゆうま
/*
写真の中の人ををゾンビっぽくします。
        
写真:	Business meeting
	http://www.flickr.com/photos/llawliet/2547595587/
	Uploaded on June 3, 2008 by llawliet
	http://creativecommons.org/licenses/by/3.0/deed.ja
*/

package
{
	import flash.display.Sprite;
	import flash.display.Loader;
	import flash.display.DisplayObject;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.net.URLRequest;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
        import flash.system.*;
  import flash.geom.Rectangle;
  import flash.geom.Point;

	public class zombi extends Sprite
	{
		private var loader:Loader;
		public function zombi():void
		{
                        var context:LoaderContext = new LoaderContext(true);
			var url:String = "http://farm4.static.flickr.com/3027/2547595587_880720367e_m.jpg";
			loader = new Loader();
			loader.load(new URLRequest(url),context);
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
			loader.addEventListener(IOErrorEvent.IO_ERROR, onLoadError);
		}
		
		//画像ロードに失敗したとき
		private function onLoadError(event:IOErrorEvent):void
		{
			//trace("load error!");
		}
		
    //画像ロード完了時
    private function onLoadComplete(event:Event):void
    {
      var SrcBmd:BitmapData = new BitmapData(loader.width, loader.height);
      var NewBmd:BitmapData = new BitmapData(loader.width, loader.height, true, 0x00ffffff);
      SrcBmd.draw(loader);
      addChild(loader);

      //ピクセル単位でRGBを調べる
      for (var py:uint = 0; py <= SrcBmd.height; py++) {
        for (var px:uint = 0; px <= SrcBmd.width; px++) {
          var RGB:uint = SrcBmd.getPixel(px, py);
          var r:uint = (RGB&0xff0000)>>16;
          var g:uint = (RGB&0x00ff00)>>8;
          var b:uint = (RGB&0x0000ff);
          //肌色の領域を抽出
          if ( r > 0xb0 && g < 0xf0 && b < 0xf0  ) {
            NewBmd.setPixel32(px, py, RGB|0xff000000);
          }
        }
      }

      // 抽出した領域の色を入れ替える
      // ColorMatrixFilter使っても良かったかも
      // HSVいじるほうの色の自然さには敵わないなぁ
      var redArray:Array = new Array(256);
      for(var i:uint=0;i<256;i++){
        redArray[i] = ((i/2)<<16) | (i<<8);
      }
      NewBmd.paletteMap(
          NewBmd,
          new Rectangle(0, 0, NewBmd.width, NewBmd.height),
          new Point(0,0),
          redArray
        );

      var DestBmp:Bitmap = new Bitmap(SrcBmd);
      DestBmp.y = SrcBmd.height;
      addChild(DestBmp);

      var AddBmp:Bitmap = new Bitmap(NewBmd);
      AddBmp.y = NewBmd.height;
      addChild(AddBmp);

      Wonderfl.capture_delay( 2 ); 
    }
  }
}