I've been working on a WPF application and need to be able to show multi-page tiffs at actual size as well as fit to screen. The code I have from another StackOverflow thread is working great for showing some of them at their actual size, however the new scanned tiff files which are around 1700 x 800 are showing up to be about 600 x 400.
What I'm trying to achieve is basically a copy of how Windows Photo Viewer shows you images. You can see them fit to the screen, or press a button and it zooms to actual size with scrollbars if needed. I have 2 tiffs that work. 1 is JPEG saved as tiff from mspaint, the other (2) is an older scanned document. 1 is 180dpi, 32 bit depth, LZW compression and 2 resolution unit, it was taken with digital camera. 2 is 200 dpi, 1 bit depth, 2 resolution unit, CCITT t.6 compression, it was a scanned document. The files that don't work are 300dpi but otherwise the same as #2.
Here is the code i'm using to show the image.
// Open a Stream and decode a TIFF image
Stream imageStreamSource = new FileStream("C:\\Users\\cblair\\Documents\\Visual Studio 2010\\Projects\\WpfApplication1\\WpfApplication1\\flowers.tif", FileMode.Open, FileAccess.Read, FileShare.Read);
TiffBitmapDecoder decoder = new TiffBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
BitmapSource bitmapSource = decoder.Frames[0];
// Draw the Image
myImage.Source = bitmapSource;
and the XML
<ScrollViewer HorizontalScrollBarVisibility="auto">
<Viewbox>
<Image x:Name="myImage" />
</Viewbox>
</ScrollViewer>