.NET 处理 tiff 文件在 XP 上会损坏,但在 Win7 上不会损坏
我需要将一些 tiff 文件读入 WPF,一切运行良好,直到我在 Windows XP 上对其进行测试。无论我如何加载,加载的图像似乎已损坏。
附件是加载相同图像的同一程序的 2 个屏幕截图 - 深色的一个是它应该的样子(从 Win7 加载),另一个是它在 XP 中加载时的样子。
我尝试过直接从 WPF 中的 Image 标记加载为 BitmapImage、BitmapSource、加载 FileStream 并传递给 BitmapImage...都具有相同类型的损坏。我已经使用 .NET LibTiff 库来解决这个问题,但它没有解释为什么会发生这种情况,而且我有点无法解释它!
编辑:我应该补充一点,图像是 16 位的。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Windows 对 TIFF 格式的支持在 XP 中非常差,但在 Windows 7 中大大增强。 XP 不支持 16 位(即仅使用 8 位)
请查看 http://msdn.microsoft。 com/en-us/library/ee720061%28VS.85%29.aspx 查看 Windows 7 中的改进内容。您还可以将其视为 W7 中修复并存在于 Windows 中的错误和限制的列表XP ....
当使用 LibTiff(或 LibTiff.NET)时,除了显示生成的位图之外,您不会使用 Windows 成像类。
我自己做了一些范围映射(16->8 位),使用 AForge.NET 进行可视化。我通过实现一个函数来实现这一点,该函数会将图块从 tiff 文件(16 位)转换为 8 位 BMP,包括图像增强(即调平)
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)
您是否尝试过使用 LibTiff 这样的外部库?
Have you tried using an external library like LibTiff?