Actionscript 3 - 在位图上绘制具有透明度的draw()
我想将透明度应用于不透明徽标,然后将其添加到图像中。 因此,我更改徽标的 alpha,然后在图像上绘制()徽标。 但它不起作用,透明度没有按预期应用。
注意:我稍后会将生成的 bitmapData 保存到文件中,因此 addChild() 不足以解决此问题。
var image:Bitmap;
var logo:Bitmap;
//...
logo.alpha = 0.3;
image.bitmapData.draw(logo);
I want to apply transparency to a non-transparent logo then add it to an image.
So I change the alpha of the logo, then I draw() the logo on the image.
But it doesn't work, the transparency isn't applied as expected.
Note: I will later save the resulting bitmapData to a file, so an addChild() won't be enough to solve this.
var image:Bitmap;
var logo:Bitmap;
//...
logo.alpha = 0.3;
image.bitmapData.draw(logo);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
当您修改位图的 alpha 值时,您并没有修改它的实际位图数据,因此当您绘制它时,您仍然复制在 bitmapData 中找到的未修改的数据。
上面的代码使用 colorTransform 属性来调整 bitmapData 中的每个像素,您可以通过更改矩形的大小来定位特定区域。
(您还需要导入 ColorTransform 类)。
try this:
When you modify the alpha value of a bitmap you aren't modifying it's actual bitmapdata, so that when you draw it you are still copying the unmodified data found in bitmapData.
The code above uses the colorTransform property to adjust every pixel in bitmapData, you can target specific areas by changing the size of the rectangle.
(You will need to import the
ColorTransform
class also).