简体   繁体   English

模拟颜色透明度

[英]Simulate color transparency

I have RGB color value and alpha value. 我有RGB颜色值和alpha值。 How can I get new RGB value assuming that I have white backgound and alpha is applied? 假设我有白色背景并应用了alpha,我怎样才能获得新的RGB值?

The formula to be applied to each of the color channels is the following: 应用于每个颜色通道的公式如下:

cr = cf * af + cb * ab * (1 - af)

where cr is the resulting color of the pixel, cf is the foreground color, cb the background color, af foreground alpha and ab background alpha. 其中cr是像素的结果颜色, cf是前景色, cb是背景色, af前景alpha和ab背景alpha。

Note that often color values are stored already premultiplied by alpha in which case the formula simplifies to 请注意,通常颜色值已经预先存储了alpha,在这种情况下公式简化为

cr = cf + cb * (1 - af)

See also alpha composing . 另见alpha合成

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM