HOWTO: Mix two colors with ALPHA?
Posted on 2003-11-05
Lets say you've got two colors... a background and a foreground. The background is BLUE [RGB(0,0,255)], the foreground is RED [RGB(255,0,0)]. Now if you want to overlay the foreground color onto the background color with varying ALPHA blending (opacity)... lets just say 150 (out of a scale of 0...255). What's the code (in C, C++, Delphi, or VB) to combine the two colors with an ALPHA value of 150? or 100? or 50?
I'm just trying to figure out how ALPHA color combining works. I know you can take the RGB value, increase, or decrease each of the R, G, and B values (min = 0, max = 255) to brighten or darken an image... but blending two RGB color values... I'm not sure what equation for that is.