I added X11 to my header search paths, library search paths, and I linked the binary to the X11 library in the build settings and build phases in XCode however I am still gettin
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.