WPF: TIFF images with JPEG compression?

て烟熏妆下的殇ゞ 提交于 2019-11-30 18:03:46

问题


I have a large number of TIFF images that I’d need to use in a WPF program (.NET 3.5 SP1 specifically and using C#). Half of the TIFF files contain color images encoded using JPEG compression and they don’t work with WPF. The “Microsoft Office Document Imaging” application handles the files fine. As Windows itself doesn’t really like them either (can’t produce thumbnails for instance) I’m assuming this is a restriction in the standard Windows Imaging Components (WIC) libraries.

Does anyone have any ideas on how to correctly read the TIFF images that are using JPEG compression with the standard .NET/WPF libraries?

Or does anyone know of any alternate third party TIFF codecs for WIC that I might be able to use to work around this issue?

Or finally are there any alternate .NET libraries for TIFF files that are still easily usable with WPF?

Thanks!


回答1:


TIFF-wrapped JPEGs come in two flavors - type 6 and type 7. What you are describing are the type 6 TIFFs. While Adobe has recommended for years that this type not be used (see Tech Note 2 for details), several graphics packages still use it.

I know of a few commercial graphics packages for .NET that can read them such as the Captiva ISIS PixTools (formerly Pixtran) libraries, but do not know offhand of anything open source or otherwise free.




回答2:


What WPF API are you using to handle them?

Have you tried using TiffBitmapDecoder from the System.Windows.Media.Imaging namespace?




回答3:


You will need to upgrade to either Windows 7, Windows Server 2008 (or newer) in order to open these files natively.

Libtiff (C++) and LibTIFF.NET (.Net) should be able to open these files. Please make sure that when you build one of these libraries, that the TIFF_JPEG (both 6 and 7) are enabled in the build. Those formats are disabled in the default build settings.



来源:https://stackoverflow.com/questions/297949/wpf-tiff-images-with-jpeg-compression

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!