Flash:通过 max(channel) 组合两个 BitmapData 对象

发布于 2024-08-19 14:58:56 字数 131 浏览 4 评论 0原文

我有两个带有 Alpha 通道的 BitmapData 对象。我想通过对每个通道(包括 Alpha)使用 max(channel_image_one,channel_image_two) 将它们组合成一个通道。有没有一种简单的方法可以达到这个结果?

I have two BitmapData objects with alpha channels. I'd like to combine them into a single one by using max(channel_image_one, channel_image_two) for each channel, including the alpha. Is there an easy way to achieve this result?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

夜司空 2024-08-26 14:58:56

我认为没有直接的位图数据方法可以通过这种方式合并 Alpha 通道。 RGB 也许可以在draw() 应用混合模式的帮助下完成,但我认为如果您需要严格的每个通道的最大值,它就不会起作用。

此外,您可以通过 PixelBender 创建一个着色器来执行此任务。它是进行此类操作的完美工具。

性能较慢,但设置速度较快,如果您不习惯 PB,您可以使用 BitmapData.getPixel32()/setPixel32() 逐一迭代/比较/写入像素。
如果您这样做,请考虑使用 BitmapData.lock()/unlock() 来提高性能。

I don't think there's straight forward bitmapdata method to merge the Alpha chanel that way. RGB could maybe do with the help of draw() applying a blend mode, but I don't think it would work if you need a strict max per chanel).

Besides, you can create a shader thanks to PixelBender to perform this task. It's the perfect tool for that kind of manipulations.

Slower in performance but quicker to setup if your not used to PB you could just iterate/compare/write the pixels one by one with BitmapData.getPixel32()/setPixel32().
In case you go for that, think about using BitmapData.lock()/unlock() to boost performance.

蓝天白云 2024-08-26 14:58:56

如果您想要 max(image_one,image_two) ,则应相当于 亮化混合模式。

以下是 Foundation ActionScript 3.0 图像效果 的片段:

public function lighten(topPixel:uint, bottomPixel:uint):uint{
   return Math.max(topPixel,bottomPixel);
}

您可以获得所需的作为源 zip 的第 2 章文件夹中的文件。

将 Theo 的建议与

  • lock()
  • 结合使用,以
  • 实现 BitmapData 的速度解锁()

或使用 PixelBender。显然,根据 Adobe 的数据,超过 90% 的 Flash Player 用户已经使用使用版本 10。

If you want max(image_one,image_two) that should be equivalent to the LIGHTEN blend mode.

Here is a snippet from Foundation ActionScript 3.0 Image Effects :

public function lighten(topPixel:uint, bottomPixel:uint):uint{
   return Math.max(topPixel,bottomPixel);
}

You can get the needed as files from the chapter 2 folder of the source zip.

Use Theo's advice with

  • lock()
  • for loops
  • unlock()

for speed with BitmapData or use PixelBender. Apparently according to Adobe, over 90% of the Flash Player user already use version 10.

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