如何在flex中使BitmapData中的颜色透明

发布于 2024-09-07 21:46:34 字数 262 浏览 0 评论 0原文

我有这样的代码:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沉睡月亮 2024-09-14 21:46:34

你已经很接近了:)

你需要告诉 bitmapData 是透明的,然后用所有透明像素填充它。

var bitmapData:BitmapData = new BitmapData(width, height, true, 0);

(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.

var bitmapData:BitmapData = new BitmapData(width, height, true, 0);

(the 0 is shorthand for 0x00000000 which is a 32 bit ARGB color expressed as a uint)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文