i am writing some C# code to alpha blend two 32bit pixels in ARGB
form like this:
Red = 0xFFFF0000 with an Alpha of 255 "FF"
Anyways, I am trying to avoid byte per byte blending like this:
public static Color Blend(this Color color, Color backColor, double amount)
{
amount = (255 - amount);
byte r = (byte)((color.R * amount / 255) + backColor.R * (255 - amount) / 255);
byte g = (byte)((color.G * amount / 255) + backColor.G * (255 - amount) / 255);
byte b = (byte)((color.B * amount / 255) + backColor.B * (255 - amount) / 255);
return Color.FromArgb(r, g, b);
}
I'm trying to make this as fast as possible without using double. Is there an equation that can alpha blend two pixels in integer form without breaking it into bytes?
P.S. I cannot use any .Net framework calls like Color.FromARGB and stuff.
Thank's