轻量级 C++ 图像库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11816571/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
light-weight C++ image library
提问by YePhIcK
I've been looking around for a simple and small yet robust and fast (notcomprehensive!) image library for C++ (C would suffice, if no C++ version is available).
我一直在寻找一个简单、小巧但健壮且快速(不全面!)的 C++ 图像库(如果没有 C++ 版本,C 就足够了)。
Main features I'm looking for are:
我正在寻找的主要功能是:
- Free (opensource is a plus)
- Built for speed
- No huge functional bloat (like
ImageMagik
, which is truly comprehensive but is a mammoth) - Tiny memory footprint
- Only supports the absolute minimum of functions like load/save, resize, convert between formats. Nothing fancy
- Error recovery for "broken" files (unlike
stb_image.c
, which has pretty poor error recovery) - MSVC and gcc friendly (I used
CxImage
for a number of years but with the latest version I'm having problems with MSVC 2010 and it would seem that active development and support for it has died out by now, so I'm about to drop it) - Should support popular modern formats, like JPEG2000, either directly or via a use of general libraries like
libpng
- Don't care if it's DirectX or OpenGL as I don't plan on using it to display the images - only to file-process them for a web site
- Having support for both static and dynamic linking is a plus
- Threading support is a huge plus
- 免费(开源是一个加分项)
- 专为速度而生
- 没有巨大的功能膨胀(例如
ImageMagik
,它确实很全面,但却是一个庞然大物) - 微小的内存占用
- 仅支持绝对最小的功能,如加载/保存、调整大小、格式之间的转换。没有什么花哨
- “损坏”文件的错误恢复(不像
stb_image.c
,它的错误恢复很差) - MSVC 和 gcc 友好(我使用
CxImage
了很多年,但在最新版本中我遇到了 MSVC 2010 的问题,现在似乎对它的积极开发和支持已经消失了,所以我准备放弃它) - 应该支持流行的现代格式,如 JPEG2000,直接或通过使用通用库,如
libpng
- 不在乎它是 DirectX 还是 OpenGL,因为我不打算使用它来显示图像 - 只是为了网站对它们进行文件处理
- 支持静态和动态链接是一个加分项
- 线程支持是一个巨大的优势
Libraries I looked at and dismissed for one reason or another:
我查看并出于某种原因解雇的图书馆:
- CxImage (no active development on it anymore)
- ImageMagik - too huge (and slow)
- stb_image.c - bad error handling, doesn't support enough image formats
- DevIL (havn't dismissed yet, but haven't looked at it much either - just learnt of it a few minutes ago on a similar post on SO) - based on it's size and feature set it looks very promising for what I need though
- FreeImage (same as DevIL - will take a look at it shortly but it's a bit big in size to my taste)
- SOIL (same as stb_image.c)
- TimThumb - it's a PHP, not a C/C++
- CxImage(不再对其进行积极开发)
- ImageMagik - 太大(而且很慢)
- stb_image.c - 错误处理错误,不支持足够的图像格式
- DevIL(还没有被解雇,但也没有看太多——几分钟前刚刚在 SO 上的一个类似帖子中了解到它)——基于它的大小和功能集,它看起来非常有希望满足我的需要
- FreeImage(与 DevIL 相同 - 很快就会看一看,但它的大小对我来说有点大)
- 土壤(与 stb_image.c 相同)
- TimThumb - 它是一个 PHP,而不是一个 C/C++
In short I just want something as tiny as possible and as fast as possible at the expense of just having the absolute bare minimum of functionality but I'm yet to find a suitable candidate thus far.
简而言之,我只是想要尽可能小和尽可能快的东西,而代价是拥有绝对最低限度的功能,但到目前为止我还没有找到合适的候选人。
Any suggestions from this community, please? But keep in mind the constraints I listed above - I don't think it's OK to throw an answer of a form "have you tried X?" where "X" doesn't meet half of my needs :)
请问这个社区有什么建议吗?但是请记住我上面列出的限制条件——我认为抛出“你试过 X 吗?”这样的形式的答案是不行的。其中“X”不能满足我一半的需求:)
Edit: Looking a bit more into DevIL it would seem it could be what I need. It's light, tiny, robust. Now I just need to make sure it performs. Oh, and CImage (I forgot to mention it in the list) - didn't like it's performance (though I have to admit that the idea of template-only implementation is cute, to say the least)
编辑:多看一点 DevIL 似乎它可能是我需要的。它轻巧、小巧、坚固。现在我只需要确保它执行。哦,还有 CImage(我忘了在列表中提到它) - 不喜欢它的性能(尽管我不得不承认仅模板实现的想法很可爱,至少可以说)
采纳答案by Gigi
I strongly suggest you to write a little library around libpngand jpeglib(and every other low-level library for the formats you need to support). It is not that hard and you can code all the features you require.
我强烈建议您围绕libpng和jpeglib(以及您需要支持的格式的所有其他低级库)编写一个小库。这并不难,您可以编写所需的所有功能。
As an alternative, you can use some of the good c++ wrappers that already exists for that libraries. Here are some examples:
作为替代方案,您可以使用该库已经存在的一些好的 c++ 包装器。这里有些例子: