在 C# 中使用 LibTiff(访问平铺的 TIFF 图像)
我想使用 LibTiff 访问非常大的 TIFF 文件。我需要多个页面和图块等功能,因此 LibTiff 似乎是正确的选择。谁能帮助我如何在 C# 中使用 LibTiff?我找到了一些链接(例如 blog.bee-ee 其中包含部分代码,但我无法超越我查看的FreeImage 但发现它不合适(图片约为 800 MPixel 8 或 16 位灰度 --> 800-1600 MByte)大小,并且我无法将其加载到 32 内存中-bit 环境)
我在 C/C++ 方面非常有经验,但在 C# 方面还没有经验。谁能帮助我包装或一些提示?
注意:我需要页面来访问 tiff 中的金字塔平面(多分辨率),并且需要 256x256 的图块来快速访问图像的不同部分,而无需立即加载图像。
[编辑] LibTIFF.NET 解决方案对我来说似乎最实用。我现在正在将它集成到产品开发中,它可能会为我省去很多进出托管内存的麻烦。我还没有尝试过“回调”功能,这似乎可以通过 .net 方式很好地解决。 感谢您在 stackoverflow 上的帮助 [/编辑]
I'd like to use LibTiff to access very large TIFF files. I need functions like multiple pages and tiles, and so LibTiff seems to be the right way to go. Can anyone help me on how to use LibTiff from C#? I've found some links (like blog.bee-ee which contained partial code. But I couln't get beyond getting a version. I've looked at FreeImage but found it not suitable (pictures are approx. 800 MPixel 8 or 16 bit grayscale --> 800-1600 MByte) size and I can't load it in memory in a 32-bit environment)
I'm very experienced in C/C++, but not yet in C#. Can anyone help me to a wrapper or some hints?
Note: I need pages to access pyramidical planes (multi-resolution) in a tiff, and tiles of 256x256 to have fast access to different parts of the image without loading it at once.
[Edit] The LibTIFF.NET solution seemed most practical for me. I'm now integrating it in a product development, and it will propably save me a lot of headaches from going in/out of managed memory. I have not yet tried the 'callback' functionality, which seems to be solved nicely in a .net way.
Thanks for the help on stackoverflow
[/Edit]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以尝试我们的 LibTiff.Net。它是使用托管 C# 编写的 LibTiff 的免费开源版本。我们实现的 API 与原始 API 非常相似。
https://bitmiracle.com/libtiff/
我们刚刚发布了它,因此可能存在错误。但完整的源代码附带了许多测试,因此最明显的错误应该得到修复。
You can try our LibTiff.Net. It is free and open source version of LibTiff written using managed C#. API of our implementation kept very similar to original one's.
https://bitmiracle.com/libtiff/
We've just released it, so there may be bugs. But full source code comes with a number of test, so most obvious bugs should be fixed.
WIC 提供对非常大的图像文件的支持。 .NET 框架中有一个很好的包装器:TiffBitmapDecoder。
WIC provides support for very large image files. There's a nice wrapper for it in the .NET framework: TiffBitmapDecoder.
我最初的解决方案是使用 LibTIFF DLL 的 C#.NET 包装器。我在 libtiff ftp 上找到了它。它似乎包含 LIBTiff 库的所有重要方法。它将内存保留在非托管 LibTIFF 内存中;这意味着 C# 代码需要意识到这一点,并在需要以安全代码处理数据时复制数据。
我用来测试它的“平铺阅读代码”读起来就像
我会选择 LibTIFF 的 .NET 端口,但这个解决方案可能适合其他人,所以我把它留在 StackOverflow 上。
My initial solution was to use a C#.NET wrapper for the LibTIFF DLL. I have found it on libtiff ftp. It seems to contain all important methods of the LIBTiff library. It keeps memory in unmanaged LibTIFF memory; this means that the C# code needs to be aware of this and copy data when it needs to be processed in safe code.
My 'tile reading code' to test it read like
I'll go for the .NET port of LibTIFF though, but this solution may be the right one for other people, so I leave it on StackOverflow.