如何混合两个ARGB像素?
如何混合两个 ARGB 像素?
示例
这里 A 是(红色Alpha) 和 B 是 ( 蓝色与 Alpha )。
How can I mix two ARGB pixels ?
Example
Here A is (Red with Alpha) and B is ( Blue with Alpha ).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
摘自您获取图像的同一篇维基百科文章:
转换为 0 到 255 范围内的值:
Taken from the same Wikipedia article where you got the image:
Translating to values which range from 0 to 255:
以上是错误的算法。
这可以通过代入 aA = 0 来验证。事实证明,如果您尝试将颜色 B 与完全透明的颜色 A(即不可见)混合,那么从逻辑上讲,颜色 B 保持不变,但根据此公式,它会发生变化。
与渐变透明度错误混合的结果。
因此,正确的解决方案应该是这样的:
与渐变透明度正确混合的结果。
The above is the wrong algorithm.
This can be verified by substituting aA = 0. Then it turns out that if you are trying to blend color B with completely transparent color A, i.e. invisible, then logically the color B remains unchanged, but according to this formula it will be changed.
The result of incorrect blending with gradient transparency.
Therefore, the correct solution would be like this:
The result of correct blending with gradient transparency.
看来这就是您想要的: http://en.wikipedia.org/wiki/Alpha_compositing #Alpha_blending,但我对你的符号有点困惑,因为维基百科说 argb 值的范围应该是从 0.0 到 1.0。所以我不认为这个公式会给你 FA=19。你能澄清一下吗?
编辑:既然你已经排除了关于 FA=19 的问题,我倾向于采用这个公式。
It seems like this is what you want: http://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending, but I'm a little confused by your notation since wikipedia says that argb values should range from 0.0 to 1.0. So I don't think this formula will give you FA=19. Can you clarify?
Edit: now that you took out the business about FA=19, I'm inclined to go with that formula.