【问题标题】:I need to view a Multipage TIFF in a WPF application我需要在 WPF 应用程序中查看多页 TIFF
【发布时间】:2011-02-15 01:56:47
【问题描述】:
我需要使用 WPF 查看多页 tiff。
我目前有以下:
<FlowDocumentReader>
<FlowDocument>
<BlockUIContainer>
<Image x:Name="DocImg" Source="test1752158790.tif" />
</BlockUIContainer>
</FlowDocument>
</FlowDocumentReader>
我只能查看第一页。
有没有办法做到这一点?
谢谢!
托德
【问题讨论】:
标签:
wpf
tiff
viewer
multipage
【解决方案1】:
我会在后面实现你自己的控制代码。您将需要一些用户输入来指示用户何时从一页转到下一页,无论是通过鼠标单击还是其他方式。
获得该用户输入后,您就可以显示 tiff 的不同页面。正如在 ChrisF 使用的问题中所说,我会使用 libtiff,更具体地说,是 .NET 包装器 FreeImage,它很好地封装了 .NET 的 tiff 功能。
【解决方案2】:
如another 问题中的回答,请使用TiffBitmapDecoder。
类似这样的:
// Decode TIFF image
ImageStream = new FileStream(EnvelopeItem.LocalImagePath, FileMode.Open, FileAccess.Read, FileShare.Read);
ImageDecoder = new TiffBitmapDecoder(ImageStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
PageImage.Source = ImageDecoder.Frames.FirstOrDefault();
在你用图像显示完你的帧之前不要释放流。