有没有一种方法可以将colorTransform应用于圆形而不是矩形中的BitmapData?
我不想像下面的代码那样通过减少alpha通道来擦除图像中的矩形部分,而是想在圆圈中进行。
_bitmap.colorTransform(new Rectangle(mouseX-d/2, mouseY-d/2, d, d),
new ColorTransform(1, 1, 1, .5, 0, 0, 0, 1));我确实有一些代码循环像素,提取Alpha值并使用setPixel,但它看起来比colorTransform函数慢得多。
发布于 2010-01-03 00:19:49
尝试使用绘图应用编程接口(flash.display.Graphics)创建一个圆,然后使用BlendMode.ERASE将其绘制到位图数据上。如果我理解正确的话,这可能会解决您的问题。
var circle : Shape = new Shape;
circle.graphics.beginFill(0xffcc00, 1);
circle.graphics.drawEllipse(-50, -50, 100, 100);
// Create a transformation matrix for the draw() operation, with
// a translation matching the mouse position.
var mtx : Matrix = new Matrix();
mtx.translate(mouseX, mouseY);
// Draw circle at mouse position with the ERASE blend mode, to
// set affected pixels to alpha=0.
myBitmap.draw(circle, mtx, null, BlendMode.ERASE);我不能100%确定ERASE blend模式是否能通过draw()命令令人满意地工作,但我不明白为什么它不能。请让我知道它是如何工作的!
https://stackoverflow.com/questions/1992004
复制相似问题