C#.NET 中的 JPEG 2000 支持
.NET 似乎无法使用 GDI 库打开 JP2 (Jpeg 2000) 文件。 我在谷歌上搜索过,但找不到任何库或示例代码来执行此操作。
有人有什么想法吗? 我真的不想花钱让图书馆来做这件事,除非我必须......
It seems that .NET can't open JP2 (Jpeg 2000) files using the GDI library. I've searched on google but can't find any libraries or example code to do this.
Anybody got any ideas? I don't really want to pay for a library to do it unless I have to..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
似乎我们可以使用 FreeImage (免费)来做到这一点
Seems like we can do it using FreeImage (which is free)
不久前我一直在寻找类似的东西,如果可以的话,我希望实现一个; 对我的问题的答复暗示没有记录了为 .Net 中的 Image 类使用的 GDI+ 执行此操作的方法。
我相信,如果您正在编写 WPF 应用程序,那么您可以通过 Windows 图像组件编解码器,可能已经有一个(询问您本地友好的搜索引擎?)
有一个选项可以使用插件,例如 DotImage 支持 JPEG2000,尽管可能还有更多“加载图像所涉及的努力”。
I was looking for something similar a while back, with a view to implementing one if I could; The responses to my question imply that there is no documented method to do this for GDI+ which the Image class in .Net uses.
I believe that if you're writing a WPF application, then you can extend the list of supported image formats through Windows Imanging Components codecs, and there may be one out there already (ask your local friendly search engine?)
There is an option to use an addon such as DotImage which supports JPEG2000, although there may be more "effort" involved in loading images.
对于任何遇到这篇旧文章的人来说,Gordon 的上述代码效果很好,但正如 jixtra 指出的那样,您确实会得到一个异常: System.DllNotFoundException: '无法加载 DLL 'FreeImage': 找不到指定的模块。 ' 通过 nuget 安装时。 通过安装 FreeImage-dotnet-core nuget 包并手动将 FreeImage.dll 添加到 bin 文件夹,我可以让它在 .net 4.6.1 中工作。 您可以在此处下载 dll:http://freeimage.sourceforge.net/download.html 。
我需要更好质量的图像来与 tesseract 一起使用,因此我做了一些小的更改,这对新 jpeg 的质量产生了巨大的影响:
For anyone coming across this old post, the above code from Gordon works great, but as jixtra pointed out, you will indeed get an exception: System.DllNotFoundException: 'Unable to load DLL 'FreeImage': The specified module could not be found.' when installing via nuget. I was able to get it working in .net 4.6.1 by installing the FreeImage-dotnet-core nuget package and manually adding the FreeImage.dll to the bin folder. You can download the dll here: http://freeimage.sourceforge.net/download.html.
I needed a better quality image to use with tesseract so I made a few minor changes which made a huge difference to the quality of the new jpeg:
我使用 Leadtools 来显示 JPEG 2000 图像。 他们提供了一个 .NET 库,包括 WPF 和 WinForms 控件来显示图像。 然而,价格相当昂贵。
I've used Leadtools to display JPEG 2000 images. They provide a .NET library including WPF and WinForms controls to display the images. However, there is a reasonably steep price tag.
如果您需要没有不安全块的完全托管解决方案,您可以使用 Jpeg2000.Net 库。 免责声明:我正在开发这个库,该库是商业性的。
以下是将 JPEG 2000 图像解码为 TIFF 的基本示例:
You can use Jpeg2000.Net library if you need a fully managed solution without unsafe blocks. Disclaimer: I am working on this library, the library is commercial.
Here is the basic sample for decoding of JPEG 2000 image to TIFF:
此外,对于当前最新的开源选项,您可以使用 Emgu CV,它是 OpenCV 的包装器。 C# 中的基本示例代码如下所示:
Also, for a currently-up-to-date, open-source option you can use Emgu CV, which is a wrapper around OpenCV. Basic example code in C# looks like: