Code: Select all
public static Color CalcColorBlend(Color start, Color end, int percentage)
...
Rectangle rect = new Rectangle(0, 0, 100, 1);
LinearGradientBrush brush = new LinearGradientBrush(rect, start, end, LinearGradientMode.Horizontal);
if (bmp == null)
{
bmp = new Bitmap(100, 1);
}
Graphics g = Graphics.FromImage(bmp);
g.FillRectangle(brush, rect);
result = bmp.GetPixel(percentage, 0);
This is the most convoluted way I can think of to blend colors, when all you have to do is the RGB intrapolation to do the same, without calling GDI stuff at all. The reason why I even found this is because each of my charts sits in its own thread and the static bmp made them conflict.
For now I just put in my own code to do the blend. But PLEASE change this in the future releases.