todd
todd

Reputation: 31

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

Upvotes: 3

Views: 5791

Answers (2)

J-DawG
J-DawG

Reputation: 1043

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.

Upvotes: 4

mmr
mmr

Reputation: 14919

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.

Upvotes: 3

Related Questions