zotty
zotty

Reputation: 817

.NET handling of tiff files corrupts on XP, but not Win7

I need to read some tiff files into a WPF, and I had it all working nicely, until I tested it on Windows XP. The image that's loaded appears to be corrupted, regardless of how I load it.

Attached are 2 screenshots of the same program loading the same image - the dark one is how it should look (loaded from Win7), the other is how it looks when loaded in XP.

I've tried loading as a BitmapImage, a BitmapSource, loading a FileStream and passing to a BitmapImage, directly from an Image tag in WPF... all have the same sort of corruption. I've used the .NET LibTiff library to get around the problem, but it doesn't explain why it happens, and I'm at a bit of a loss to explain it!

Edit: I should add that the image is 16 bit.

Loaded in Windows 7 Loaded in XP

Upvotes: 1

Views: 835

Answers (2)

Adriaan
Adriaan

Reputation: 3312

The support from Windows for the TIFF format is very poor in XP and greatly enhanced in Windows 7. 16 bit is not supported by the XP (that is, it only uses 8 bit) Please have a look at http://msdn.microsoft.com/en-us/library/ee720061%28VS.85%29.aspx to see what is improved in Windows 7. You can also see it as a list of bugs and limitations fixed in W7, and present in Windows XP....

When using LibTiff (or LibTiff.NET), you won't be using the windows imaging class, other than to display a resulting bitmap. I did some range mapping (16->8 bit) my self, using AForge.NET to visualize. I did this by implementing a function which would translate a tile from my tiff file (16 bit) into a 8 bit BMP, including image enancement (i.e. leveling)

Upvotes: 1

Joel Lucsy
Joel Lucsy

Reputation: 8706

Have you tried using an external library like LibTiff?

Upvotes: 1

Related Questions