Simulate color transparency

核能气质少年 提交于 2021-02-18 21:30:09

问题


I have RGB color value and alpha value. How can I get new RGB value assuming that I have white backgound and alpha is applied?


回答1:


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.

Note that often color values are stored already premultiplied by alpha in which case the formula simplifies to

cr = cf + cb * (1 - af)

See also alpha composing.



来源:https://stackoverflow.com/questions/11447830/simulate-color-transparency

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!