Threshold and mask
Hi everyone.
I need to remove only dark red in a bitmapdata.
I wrote below code where I create gradient fill of red-black, red-white, blue-black and blue-white for test purposes.
Draw that to bitmapdata and then try to use threshold method to do it.
Whatever I set mask an copysource parameters of that method I can't succeed.
I thought that mask parameter is for setting a channel, so if I set it to 0xFFFF0000 I set red channel with full alpha as a target of operation. But that doesn't happen.
Instead all dark colors are replaced and also some blue-light.
Please help me out.
CODE:
var rec:Rectangle = new Rectangle(0,0,50,200);
var m:Matrix = new Matrix;
m.createGradientBox(rec.width,rec.height, Math.PI / 2);
var r:Shape = new Shape;
//RED
r.graphics.beginGradientFill(GradientType.LINEAR, new Array(0xFF0000,0x000000),new Array(1,1),new Array(0,255), m);
r.graphics.drawRect(0,0,rec.width,rec.height);
addChild(r);
m.createGradientBox(rec.width,rec.height, Math.PI / 2, 50);
r.graphics.beginGradientFill(GradientType.LINEAR, new Array(0xFF0000,0xFFFFFF),new Array(1,1),new Array(0,255), m);
r.graphics.drawRect(50,0,rec.width,rec.height);
//BLUE
m.createGradientBox(rec.width,rec.height, Math.PI / 2, 100);
r.graphics.beginGradientFill(GradientType.LINEAR, new Array(0x0000FF,0x000000),new Array(1,1),new Array(0,255), m);
r.graphics.drawRect(100,0,rec.width,rec.height);
m.createGradientBox(rec.width,rec.height, Math.PI / 2, 150);
r.graphics.beginGradientFill(GradientType.LINEAR, new Array(0x0000FF,0xFFFFFF),new Array(1,1),new Array(0,255), m);
r.graphics.drawRect(150,0,rec.width,rec.height);
//BITMAPDATA
var bd:BitmapData = new BitmapData(200,200,true,0);
bd.draw(r);
bd.threshold(bd,bd.rect,new Point,'<', 0xFFAA0000, 0xFF, 0xFFFF0000, false);
var b:Bitmap = new Bitmap(bd);
addChild(b);
b.y = 200;

Four top strips is before threshold.
Four bottom is after use of threshold.
