如何将某种颜色设置为透明?
我使用 copyPixels
将较大位图的一部分复制到较小的位图以用于单个影片剪辑。然而,周围仍然存在一些额外的空白空间和位图边缘周围的角点。如何将位图中的白色设置为透明,这样我就不会看到这些难看的边缘?
I'm using copyPixels
to copy a parts of a larger Bitmap to smaller Bitmaps to use for individual MovieClips. However, around there is still some extra space white space and corners around the Bitmaps' edges left over. How do I set the color white in the Bitmap to be transparent so I won't see these unsightly edges?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 BitmapData .threshold 方法。此代码创建一个蓝色背景上有红色方块的 BitmapData,然后使用阈值方法使红色像素透明。
You can use the BitmapData.threshold method. This code creates a BitmapData with a red square on a blue background, then uses the threshold method to make the red pixels transparent.
您可以使用
BitmapData.colorTransform()
或draw()
而不是copyPixels()
来调整颜色you can use
BitmapData.colorTransform()
ordraw()
instead ofcopyPixels()
to adjust color there