Tamilvanan - 2013-11-07

The problem is different friend.

It's actually because of the invalidate() function that is called everytime after updating the graph.

Just run validate() function before getimage() or save() funtion and the problem won't occur.

Ex.

In my program the zedgraph control is named, graph_live.

Everytime I update the graph with new plots, I run the following two lines to ensure it updates on screen.

graph_live.AxisChange();
graph_live.Invalidate();

So, when I'm saving an image, It is necessary to run the below function before saving it,

graph_live.Validate(); // Ignoring this line of code causes the GDI+ error

try
{

using (Bitmap newlog = new Bitmap(graph_live.GraphPane.GetImage()))
{
newlog.Save("C:/img08.png", System.Drawing.Imaging.ImageFormat.Png);
}

}

catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}