/// <summary> /// Create the plot, and convert it to an XImage. Remember to dispose of the returned object, and that this MUST be run with threading ApartmentState.STA /// </summary> /// <param name="results"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="resolution"></param> /// <returns></returns> private XImage CreatePlotBitmapWpf(List <CompoundData> results, int width, int height, int resolution = 96) { var plot = Plotting.CreatePlot(results, DatasetName); var bitmap = Plotting.ConvertToBitmapImage(plot, width, height, resolution); bitmap.Freeze(); var image = XImage.FromBitmapSource(bitmap); return(image); }
/// <summary> /// Create the plot, and convert it to an XImage. Remember to dispose of the returned object, and that this MUST be run with threading ApartmentState.STA /// </summary> /// <param name="results"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="resolution"></param> /// <returns></returns> private XImage CreatePlot(List <CompoundData> results, int width, int height, int resolution = 96) { var plot = Plotting.CreatePlot(results, DatasetName, Plotting.ExportFormat.PDF); using (var memStream = new MisbehavingMemoryStream()) { memStream.PreventDispose = true; Plotting.SavePlotToPdf(memStream, plot, width, height); memStream.Seek(0, SeekOrigin.Begin); var pdfForm = XPdfForm.FromStream(memStream); memStream.PreventDispose = false; return(pdfForm); } }