繁体   English   中英

如何在UWP中将Oxyplot导出为PNG?

[英]How to export Oxyplot to PNG in UWP?

我正在将Oxyplot用于UWP,并想将我的绘图导出到png。 可以在UWP中导出为PDF,但是我想知道是否存在可以导出为PNG的方法。 我知道可以在WPF中导出到PNG,但尚不支持UWP中的PngExporter,如下所示:

using (var stream = File.Create(ApplicationData.Current.LocalFolder.Path + "\\" + "test.png"))
{
    var pngExporter = new PngExporter { Width = 800, Height = 400 };
    pngExporter.Export(PluggingPlot, stream);
}

这是其文档文档中包含的部分: 文档图片

尝试在UWP上安装这些库中的任何一个时,都会导致应用程序出现错误和功能问题,这是可以预期的。

UWP的此PNG问题是否有任何解决方法? 还是PDF是我唯一可用的导出选项? 可以导出为PDF,然后将PDF转换为PNG吗? 感谢您对解决方法的任何帮助!

如何在UWP中将Oxyplot导出为PNG?

目前,Oxyplot还没有提供在UWP平台内将PDF转换为PNG的功能。 但是,您可以使用PDFTron将PDF转换为png。 和此代码示例 要将pdf转换为png,请检查PDFDraw类。

try
{
    // A) Open the PDF document.
    using (PDFDoc doc = new PDFDoc(Path.Combine(InputPath, "tiger.pdf")))
    {
        // Initialize the security handler, in case the PDF is encrypted.
        doc.InitSecurityHandler();

        // B) The output resolution is set to 92 DPI.
        draw.SetDPI(92);

        // C) Rasterize the first page in the document and save the result as PNG.
        pdftron.PDF.Page pg = doc.GetPage(1);
        String output_file_path = Path.Combine(OutputPath, "tiger_92dpi.png");
        draw.Export(pg, output_file_path);
        WriteLine(String.Format("Example 1: Result saved in {0}", output_file_path));
        await AddFileToOutputList(output_file_path).ConfigureAwait(false);

        // Export the same page as TIFF
        output_file_path = Path.Combine(OutputPath, "tiger_92dpi.tif");
        draw.Export(pg, output_file_path, "TIFF");
        await AddFileToOutputList(output_file_path).ConfigureAwait(false);
    }
}
catch (Exception e)
{
    WriteLine(GetExceptionMessage(e));
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM