Game Engine

Linear Alpha Blending

With two images that are .bmg 32-bit incoded (aa rr gg bb) there wil be an alpha chanel that we can use to blend two images together. First we load the image that will be in the background to a window buffer and then we load the forground image. When blending the pixels in the forground image, we will need this alpha chanel to deside how much of the background should be visable and how much of the forground should be visable. To do this we will take each of the RGB color chanels and apply a technique known as Linear Alpha Blending. To do this we use the following equation.

$$ Output Color Channel = \ ((1 - Alpha Percentage)*Background Color Channel)\

  • (Alpha Percentage * Forground Color Channel) \ $$

Where AlphaPercentage is between 0.00 - 1.00 and the color channels are tipical 8-bit values. We can obtain the AlphaPercentage by dividing the Alpha channel by 255.0.