![]() | |
| |
The CImg Library is an image processing library, designed for C++ programmers. It provides useful classes and functions to load/save, display and process various types of images. Library structureThe CImg Library consists in a single header file The header file
The CImg Library is structured as follows :
Knowing these four classes is enough to get benefit of the CImg Library functionalities. CImg version of "Hello world".Below is some very simple code that creates a "Hello World" image. This shows you basically how a CImg program looks like. #include "CImg.h"
using namespace cimg_library;
int main() {
CImg<unsigned char> img(640,400,1,3); // Define a 640x400 color image with 8 bits per color component.
img.fill(0); // Set pixel values to 0 (color : black)
unsigned char purple[] = { 255,0,255 }; // Define a purple color
img.draw_text(100,100,"Hello World",purple); // Draw a purple "Hello world" at coordinates (100,100).
img.display("My first CImg code"); // Display the image in a display window.
return 0;
}
Which can be also written in a more compact way as : #include "CImg.h"
using namespace cimg_library;
int main() {
const unsigned char purple[] = { 255,0,255 };
CImg<unsigned char>(640,400,1,3,0).draw_text(100,100,"Hello World",purple).display("My first CImg code");
return 0;
}
Generally, you can write very small code that performs complex image processing tasks. The CImg Library is very simple to use and provides a lot of interesting algorithms for image manipulation. How to compile ?The CImg library is a very light and user-friendly library : only standard system libraries are used. It avoids handling complex dependencies and problems with library compatibility. The only thing you need is a (quite modern) C++ compiler :
If you are using other compilers and encounter problems, please write me since maintaining compatibility is one of the priorities of the CImg Library. Nevertheless, old compilers that do not respect the C++ standard will not support the CImg Library. What's next ?If you are ready to get more, and to start writing more serious programs with CImg, you are invited to go to the Tutorial : Getting Started. section. Class representing an image (up to 4 dimensions wide), each pixel being of type T. Definition: CImg.h:2288 CImg< T > & draw_text(const int x0, const int y0, const char *const text, const tc1 *const foreground_color, const tc2 *const background_color, const float opacity, const CImgList< t > &font,...) Draw a text string. Definition: CImg.h:46072 |
Copyrights (C) From october 2004, David Tschumperlé - GREYC UMR CNRS 6072, Image team. Copyrights (C) January->September 2004, David Tschumperlé. Copyrights (C) 2000->2003, David Tschumperlé - INRIA Sophia-Antipolis. Odyssée group. |