public static void Export(PlotModel model, string fileName, int width, int height, Brush background = null)
{
using (var bm = new Bitmap(width, height))
{
using (Graphics g = Graphics.FromImage(bm))
{
if (background != null)
g.FillRectangle(background, 0, 0, width, height);
var rc = new GraphicsRenderContext { RendersToScreen = false };
rc.SetGraphicsTarget(g);
model.Update();
model.Render(rc, width, height);
bm.Save(fileName, ImageFormat.Png);
}
}
}