How to open PNG with CImg library without losing alpha channel?

那年仲夏 提交于 2019-12-03 21:50:31

CImg is a very good library to work with .png files (incl. 4-channels). For a native support of png files by CImg, you need to link your code with the libpng library, otherwise CImg will use an external call to ImageMagick's convert tool to read the .png file. To enable the full .png support in CImg, just compile your code with the 'cimg_use_png' macro defined, and link it with libpng, and you're done :

g++ -o foo foo.cpp -Dcimg_use_png -lpng -lz -lX11 -lpthread

I found CImg to be one of the library with the most complete support of .png and .tiff files, you only have to define some configuration flags to allow it using the proper libraries. By default, CImg is configured to use a minimal set of libraries.

Suggestion for another library (that I have used and imo is quite easy): http://www.imagemagick.org/script/api.php#c

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