简体   繁体   中英

Simulate color transparency

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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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