通过组合两种颜色确定接收到的 RGBA 颜色 [英] Determine RGBA colour received by combining two colours
问题描述
我有两种颜色定义为 RGBA(在我的具体示例中,其中一种颜色是 [white with alpha 0.85] 和 [57, 40, 28 with alpha 0.25].第二种颜色绘制在第一种颜色上(即带有 alpha 的白色是背景,第二种颜色用于绘图.我怎样才能弄清楚组合的 RGBA 颜色是什么?我需要一次性完成 - 所以任何工具都可以(例如我很高兴在 Photoshop 中画一些东西,看看会出现什么).
I have two colours defined as RGBA (in my specific examples, one of the set is [white with alpha 0.85] and [57, 40, 28 with alpha 0.25]. The second colour is drawn over the first one (i.e. white with alpha is the background and the second colour is used for drawing). How can I figure out what the RGBA colour of the combination is going to be? I need to do this one-off - so any tools is fine (e.g. I'm happy to draw something in photoshop and see what comes out).
我有几套要组合,但不要太多.任何指针?谢谢.
I have several sets to combine, but not too many. Any pointers? Thanks.
推荐答案
当使用Painter's algorithm 大部分颜色合成使用Porter-DuffOver"模式完成:
When using Painter's algorithm most color compositing is done using Porter-Duff "Over" mode:
最终的 alpha:
αr = αa + αb (1 - αa)
产生的颜色分量:
Cr = (Ca αa + Cb αb (1 - αa)) / αr
例如:
alpha = 0.25 + 0.85 * (1 - 0.25) = 0.8875
red = (57 * 0.25 + 255 * 0.85 * (1 - 0.25)) / 0.8875 = 199.2
green = (40 * 0.25 + 255 * 0.85 * (1 - 0.25)) / 0.8875 = 194.4
blue = (28 * 0.25 + 255 * 0.85 * (1 - 0.25)) / 0.8875 = 191.1
请参阅关于 alpha 合成的维基百科文章.
See wikipedia article on alpha compositing.
这篇关于通过组合两种颜色确定接收到的 RGBA 颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!