blend colors in C#
public static System.Drawing.Color BlendColors(System.Drawing.Color color1, System.Drawing.Color color2)
{
int size = 500;
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(size, size);
using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bmp))
{
System.Drawing.Brush gb = new System.Drawing.Drawing2D.LinearGradientBrush(new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), color1, color2, 90);
graphics.FillRectangle(gb, new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height));
}
return bmp.GetPixel(size, 85);
}
// since Microsoft already programmed a way to blend colors using LinearGradientBrush and we don't know it,
// i decided to use the Bitmap.GetPixel(x, y) method to retrieve the color of the center pixel, well actually a few pixels higher,
// and then return it through the method
//
// and BOOM! easy color blending... kinda...