圆形颜色变换
有没有办法将 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 函数明显慢得多。
Is there a way to apply a colorTransform to a BitmapData in a circle rather than in a rectangle?
Instead of erasing rectangular parts of an image by reducing the alpha channel as in the code below, I'd like to do it in circles.
_bitmap.colorTransform(new Rectangle(mouseX-d/2, mouseY-d/2, d, d),
new ColorTransform(1, 1, 1, .5, 0, 0, 0, 1));
I do have some code which loops through the pixels, extracts the alpha value and uses setPixel but it seams significantly slower than the colorTransform function.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用绘图 API (flash.display.Graphics) 创建一个圆,然后使用 BlendMode.ERASE 将其绘制到位图数据上。如果我理解正确的话,这可能会解决你的问题。
我不能 100% 确定 ERASE 混合模式能够与 draw() 命令配合使用,但我不明白为什么它不能。请让我知道结果如何!
Try creating a circle using the drawing API (flash.display.Graphics) and then drawing that onto the bitmap data with BlendMode.ERASE. That might solve your problem, if I understand it correctly.
I'm not 100% sure that the ERASE blend mode works satisfyingly with the draw() command, but I can't see why it shouldn't. Please let me know how it works out!