I need to view a Multipage TIFF in a WPF application
I need to view a multipage tiff with WPF.
I currently have the following:
<FlowDocumentReader>
开发者_如何学运维 <FlowDocument>
<BlockUIContainer>
<Image x:Name="DocImg" Source="test1752158790.tif" />
</BlockUIContainer>
</FlowDocument>
</FlowDocumentReader>
I can only view the first page.
Is there a way to do this?
Thanks! Todd
As answered in another question, use TiffBitmapDecoder.
Something like this:
// 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();
Don't dispose of the stream until you're done displaying your frames with the image though.
I would implement your own control code in the back. You're going to need some user input to indicate when the user goes from one page to the next, be it via mouse click or whatever.
Once you get that user input, you can then show a different page of the tiff. And as was said in the question ChrisF used, I'd go with libtiff, more specifically, the .NET wrapper FreeImage that nicely encapsulates tiff functionality for .NET.
精彩评论