こんにちは私はビットマップの特定の色を別の色に置き換えたいと思います。BitmapData.threshold()関数は、しきい値の色の値にアルファがない場合に正常に機能します。
var threshold:uint = 0xFF004d5e; // this works, however if I use this 0x37004d5e, ie the same color with an alpha then it doesnt
var baseColour:uint = 0x3700c5e0;
var targetColour:uint = 0x37F38900;
var inputBitmapData:BitmapData = new BitmapData(200, 200, true, baseColour);
inputBitmapData.fillRect(new Rectangle(10, 10, 180, 180), threshold);
var input:Bitmap = new Bitmap(inputBitmapData);
addChild(input);
replaceColour(inputBitmapData,threshold,targetColour);
function replaceColour(bitmapData:BitmapData,colorToReplace:uint, newColor:uint):void
{
trace(" replaced:"+ bitmapData.threshold(bitmapData, new Rectangle(0, 0, bitmapData.width, bitmapData.height), new Point(), "==", colorToReplace, newColor, 0xFFFFFFFF));
}
上記は、アルファのある色を変更しようとしない限り、機能しません。つまり、しきい値変数の値を0xFF004d5eから0x37004d5eに変更します。つまり、アルファチャネルを持つ色を変更すると、機能しなくなりますが、それが必要です。しきい値の色にアルファがある場合にBitmapData.threshold()関数を機能させる方法はありますか?