0

Currently I am able to export one PlotModel as a .png at a time, using:

public void CreatePNG(PlotModel plotModel, string fileName, Stream stream)
{
    var pngExporter = new PngExporter { Width = 600, Height = 400, Background = OxyColors.White };
    pngExporter.Export(plotModel, stream);        
}

Here is the .png output of the PlotModel enter image description here

Is there a way to export 2 PlotModels such that they look like this in the .png file?

enter image description here

Or, can I concatenate 2 .png files??

Georgiana M
  • 323
  • 4
  • 20

1 Answers1

0

I figured out how to export multiple OxyPlot plots in a .png file, by converting them into Bitmap.

Here a sample code:

            var stream1 = new MemoryStream();
            var stream2 = new MemoryStream();
            var pngExporter = new PngExporter {Width = 600, Height = 400, Background = OxyColors.White};
            var pngExporter2 = new PngExporter {Width = 600, Height = 400, Background = OxyColors.White};
            pngExporter.Export(plotModel1, stream1);
            pngExporter2.Export(plotModel2, stream2);

            System.Drawing.Bitmap b1 = new System.Drawing.Bitmap(Image.FromStream(stream1));
            System.Drawing.Bitmap b2 = new System.Drawing.Bitmap(Image.FromStream(stream2));

            System.Drawing.Bitmap img = new System.Drawing.Bitmap(600, 800);
            Graphics g = Graphics.FromImage(img);

            g.DrawImage(b1, 0, 0);
            g.DrawImage(b2, 0, 400);

            img.Save(stream.ToString());
Georgiana M
  • 323
  • 4
  • 20