将 CoreGraphics 混合模式映射到 Porter-Duff

发布于 2024-10-08 03:29:13 字数 628 浏览 0 评论 0原文

我有一个 iPhone 应用程序,它通过 CoreGraphics(特别是 CGContextSetBlendMode)混合两个 UIImage 对象来进行图像操作。我目前正在研究将其移植到 Android 上。我已经完成了使用 PorterDuff 模式在 Android 上组合到 Bitmap 对象的过程。然而,我想要更复杂的合成。例如,我对许多混合使用 kCGBlendModeHardLight

要么乘以颜色,要么屏蔽颜色, 取决于源图像样本 颜色。如果源图像样本 颜色比 50% 灰色浅, 背景变亮,类似于 筛选。如果源图像样本 颜色比 50% 灰色深, 背景变暗,类似于 倍增。如果源图像 样本颜色等于 50% 灰色,则 源图像未更改。图像 等于纯黑色的样品 或纯白色导致纯黑色或 白色的。整体效果是类似的 到你通过闪耀而获得的成就 源图像上的强烈聚光灯。 使用它可以向场景添加高光。

但无论如何(如果可能的话)不知道如何通过 Porter-Duff 来模拟这一点。 Android 不支持更好的开箱即用的图像处理算法吗?是否可以以某种方式使用 Porter-Duff 来模拟更高级的混合模式?

I have an iPhone app that does image manipulation via blending two UIImage objects via CoreGraphics, specifically CGContextSetBlendMode. I am currently researching porting it to Android. I've gone through the process of combining to Bitmap objects on Android using PorterDuff modes. However, I want much more complicate compositing. For example, I'm using kCGBlendModeHardLight for many blends:

Either multiplies or screens colors,
depending on the source image sample
color. If the source image sample
color is lighter than 50% gray, the
background is lightened, similar to
screening. If the source image sample
color is darker than 50% gray, the
background is darkened, similar to
multiplying. If the source image
sample color is equal to 50% gray, the
source image is not changed. Image
samples that are equal to pure black
or pure white result in pure black or
white. The overall effect is similar
to what you’d achieve by shining a
harsh spotlight on the source image.
Use this to add highlights to a scene.

But don't know of anyway (if it's even possible) to emulate this via Porter-Duff. Does Android not support better Image Manipulation algorithms out of the box? Is it possible to use Porter-Duff in some way to emulate more advanced blend modes?

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

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

发布评论

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

评论(1

淡忘如思 2024-10-15 03:29:13

除了 12 个 Porter-Duff 混合方程外,Android 还支持 Lighten、Darken、Multiply、Screen 以及即将推出的 Overlay。不幸的是,这意味着 HardLight 不可用,您必须自己实现它。

In addition to the 12 Porter-Duff blending equations, Android supports Lighten, Darken, Multiply, Screen and soon Overlay. Unfortunately this means HardLight is not available and you would have to implement it yourself.

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