[英]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.