Question

When i use bitmapdata threshold, what happens to the pixels that fail the threshold test? As per my observation they remain as in, so is there any way to remove them?

Was it helpful?

Solution

The best way would be to use a temporary (static, reusable) transparent BitmapData for this operation. You fill it with 0x0, then call threshold() setting source to your BitmapData, and copySource flag set to false, then you copyPixels() back with mergeAlpha set to false.

var tbd:BitmapData=yourBitmapData.clone(); // this makes a new BitmapData, so be warned
var p0:Point=new Point();
tbd.fillRect(tbd.rect,0);
tbd.threshold(yourBitmapData,yourBitmapData.rect,p0,yourOperation,
    yourThreshold,yourColor,yourMask,false);
yourBitmapData.copyPixels(tbd,tbd.rect,p0);
tbd.dispose();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top