是否可以在一个.png文件中导出2个OxyPlot PlotModel?

时间:2016-06-03 12:35:17

标签: plot export png oxyplot

目前,我可以一次导出一个PlotModel作为.png,使用:

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

以下是.png的{​​{1}}输出 enter image description here

有没有办法导出2个PlotModel,使它们在PlotModel文件中看起来像这样?

enter image description here

或者,我可以连接2个.png个文件吗?

1 个答案:

答案 0 :(得分:0)

我想出了如何在OxyPlot文件中导出多个.png图表,方法是将它们转换为Bitmap

这是一个示例代码:

            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());