Note that there are some explanatory texts on larger screens.

plurals
  1. POTiff images aren't showing actual size in WPF Image control
    text
    copied!<p>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. </p> <p>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.</p> <p>Here is the code i'm using to show the image.</p> <pre><code>// 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; </code></pre> <p>and the XML</p> <p><code> &lt;ScrollViewer HorizontalScrollBarVisibility="auto"&gt; &lt;Viewbox&gt; &lt;Image x:Name="myImage" /&gt; &lt;/Viewbox&gt; &lt;/ScrollViewer&gt;</code></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload