Save Plot to image

Oct 9, 2013 at 2:16 PM
Hi everyone,
I am trying to create a report which is supposed to include plot graphics and data (from other views in the application). Now I have checked the documentation and forums, and it seems that there is no ToImage() method in OxyPlot.WPF, neither there are SaveBitmap, ToBitmap methods mentioned in elswwhere, only ToCode and ToSVG which are of no use in my scenario. So my question is is there a simple, or relatively simple, way to get the plot as image?
Oct 10, 2013 at 11:36 AM
Edited Oct 10, 2013 at 11:36 AM
You can simply do a CTRL+C to copy the plot to the clipboard? Might point you in the right direction.
Oct 10, 2013 at 12:39 PM
CTRL+C works, but what I need is to call it from my ViewModel, but I can not call
System.Windows.Input.ApplicationCommands.Copy.Execute(null, PlotModel);  
as PlotModel is not of IInputElement type.
Oct 11, 2013 at 4:04 PM
Edited Oct 11, 2013 at 4:08 PM
Why don't you use the PngExporter?
Usage example:
PngExporter.Export(this.PlotModel, stream, 800, 600);
That creates the image in the form of a PNG in the stream (for example a filestream or a memory stream.

You can also use
BitmapSource bitmap = PngExporter.ExportToBitmap(this.PlotModel, width, height, backgroundColor);
This create a BitmapSource that can easily be added to the clipboard or used any way you want.

Hope this helps.
Oct 14, 2013 at 11:20 AM
Thanks Gimly, tthat solves my issues.