【问题标题】:Is it possible to export 2 OxyPlot PlotModels in one .png file?是否可以在一个 .png 文件中导出 2 个 OxyPlot PlotModels?
【发布时间】:2016-06-03 12:35:17
【问题描述】:

目前我可以一次将一个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);        
}

这是PlotModel.png 输出

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

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

【问题讨论】:

    标签: plot export png oxyplot


    【解决方案1】:

    我想出了如何在.png 文件中导出多个OxyPlot 绘图,方法是将它们转换为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());
    

    【讨论】:

    • PngExporter 不幸的是,OxyPlot 中不再存在。 :-(
    猜你喜欢
    • 1970-01-01
    • 2017-03-01
    • 2020-01-02
    • 1970-01-01
    • 1970-01-01
    • 2010-09-13
    • 1970-01-01
    • 2019-09-10
    • 1970-01-01
    相关资源
    最近更新 更多