X11 Problems when using CImg header in XCode on Mac OSX 10.11.6

我们两清 提交于 2019-12-02 03:56:16

I think you have your build settings a little incorrect. Here is a very simple program to get you started - you can choose to display PNG, TIFF or JPEG files by using libpng, libtiff or libjpeg which I am assuming you have installed using homebrew with:

brew install libpng libjpeg libtiff

Here is the code:

#define cimg_display  1
#define cimg_use_png  1
#define cimg_use_tiff 1
#define cimg_use_jpeg 1

#include "CImg.h"
using namespace cimg_library;

int main() {
    // Load image
    CImg<unsigned char> image("/Users/mark/Desktop/test.tif");

    // CImg<unsigned char> image("/Users/mark/Desktop/test.png");
    // CImg<unsigned char> image("/Users/mark/Desktop/test.jpg");
    // CImg<unsigned char> image("/Users/mark/Desktop/test.pnm");

    image.display();
}

The only build settings needed are as follows:

and

The /Users/mark/src/CImg one is for the CImg.h header file I manage with git, keeping it in sync with the CImg distribution on GitHub.

Note the following:

  • CImg can read NetPBM (PGM/PBM/PPM and actually PFM) images without any extra code or libraries or dependencies

  • CImg can read TIFF, PNG, JPEG without needing ImageMagick if you #define cimg_use_tiff or #define cimg_use_png or #define cimg_use_jpeg as long as you set the include path the library path and the library names as I have shown above.

  • CImg can read anything that ImageMagick can read if you install that package.

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