Flash as3 smooth threshold

Posted by arkzai on Stack Overflow See other posts from Stack Overflow or by arkzai
Published on 2010-04-24T09:03:21Z Indexed on 2010/04/24 9:13 UTC
Read the original article Hit count: 398

Filed under:
|

hello, I'm building a flash app that pulls images from flickr and removes the white background I'm dong this using threshold and i get a really ragged outcome is there any way to get a better and smoother color key? thanks photoNumber = Math.floor(Math.random() * (photos.length));

    loader.load(new URLRequest(photos[photoNumber].path));
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE,draw);
    trace ( "trying to load photo " + photoNumber );

    function draw(e:Event) {

    trace ("show photo " + photoNumber)

var W:int=e.target.content.width;
var H:int=e.target.content.height;

bitmapdata=new BitmapData(W,H);
bitmap=new Bitmap(bitmapdata);
bitmapdata.draw(e.target.content);

    var threshold:uint =  0xF9F8F800;
    var color:uint = 0x00000000;
    var maskColor:uint = 0x00FF0000;

bitmapdata.threshold(bitmapdata,new Rectangle(0,0,W,H),new Point(0,0),">", threshold, color, maskColor, true);

    bitmap.smoothing = true;
    //bitmap.scaleX = bitmap.scaleY = 0.99; // <----
    imgHolder.addChild(bitmap);

    }

}

© Stack Overflow or respective owner

Related posts about flash

Related posts about actionscript