Save Plot to image

Oct 9, 2013 at 1: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?
Regards,
Bolek.
Oct 10, 2013 at 10:36 AM
Edited Oct 10, 2013 at 10: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 11:39 AM
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 3:04 PM
Edited Oct 11, 2013 at 3: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 10:20 AM
Thanks Gimly, tthat solves my issues.
Regards,
Bolek.