如何在flex中使BitmapData中的颜色透明
我有这样的代码:
var bitmapData:BitmapData = new BitmapData(width, height);
bitmapData.draw(this);
var ba:ByteArray = (new PNGEncoder()).encodeByteArray(bitmapData.getPixels(clipRect),width,height,true);
我想让生成的PNG中的白色透明。最好的方法是什么?
I have a code like this:
var bitmapData:BitmapData = new BitmapData(width, height);
bitmapData.draw(this);
var ba:ByteArray = (new PNGEncoder()).encodeByteArray(bitmapData.getPixels(clipRect),width,height,true);
I want to make the white color in the generated PNG transparent. What is the best way to do so?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你已经很接近了:)
你需要告诉 bitmapData 是透明的,然后用所有透明像素填充它。
(0 是 0x00000000 的简写,它是表示为 uint 的 32 位 ARGB 颜色)
You were close :)
You need to tell the bitmapData to be transparent, and then fill it with all transparent pixels.
(the 0 is shorthand for 0x00000000 which is a 32 bit ARGB color expressed as a uint)