[英]GIF/ISF image in Xfinium.PDF PdfFlowDocument
我正在將Xfinium.PDF組件用於UWP。 我需要顯示使用ISF編碼為GIF的圖像(此處是更多信息: https : //docs.microsoft.com/zh-cn/windows/uwp/input-and-devices/save-and-load-ink )。 我只有字節流,沒有物理圖像。
當我使用PdfFlowDocument時,我需要實例化一個PdfFlowTableImageCell。
我該怎么做?
您必須使用BitmapDecoder / BitmapEncoder UWP類將GIF圖像轉換為PNG(或JPEG),然后創建可在PdfFlowTableImageCell中使用的PdfPngImage(或PdfJpegImage)。
更新:以下代碼顯示了如何在UWP中將GIF圖像轉換為PNG(假定您的GIF圖像在流中):
// Stream gifStream = your image stream
BitmapDecoder gifDecoder =
await BitmapDecoder.CreateAsync(gifStream.AsRandomAccessStream());
BitmapFrame gifFrame = await gifDecoder.GetFrameAsync(0);
PixelDataProvider gifPixels = await gifFrame.GetPixelDataAsync();
InMemoryRandomAccessStream pngStream = new InMemoryRandomAccessStream();
BitmapEncoder pngEncoder =
await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, pngStream);
pngEncoder.SetPixelData(BitmapPixelFormat.Rgba8, BitmapAlphaMode.Straight,
gifFrame.PixelWidth, gifFrame.PixelHeight,
96, 96, gifPixels.DetachPixelData());
await pngEncoder.FlushAsync();
pngStream.Seek(0);
PdfPngImage pngImage = new PdfPngImage(pngStream.AsStream());
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.