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?
rgb() The rgb() functional notation expresses a color according to its red, green, and blue components. An optional alpha component represents the color's transparency.
The impression of transparency can be achieved when two sets of color are joined by a third that is perfectly balanced between them. Split the difference between the luminosity, hue, and saturation of the two to arrive at the third.
Simulated Transparency - A color illusion in which opaque media is used to create an illusion of transparency.
Make transparent colors in RThe rgb() command is the key: you define a new color using numerical values (0–255) for red, green and blue. In addition, you set an alpha value (also 0–255), which sets the transparency (0 being fully transparent and 255 being “solid”).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With