CImg: hello world

I implemented CImg hello world that loads an image, display on a CImg window, and save it. The complete code is available on my github.

#include <iostream>
#include <string>
#include <CImg.h>
int main()
{
std::cout << "run CImg hello world..." << std::endl;
cimg_library::CImg<unsigned char> img;
std::string strFileInput = "lena.pgm";
std::string strFileOutput = "lena.bmp";
img = cimg_library::CImg<unsigned char>(strFileInput.c_str());
std::cout << "load " << strFileInput << "..." << std::endl;
std::cout << "width = " << img.width() << std::endl;
std::cout << "height = " << img.height() << std::endl;
std::cout << "color = " << img.spectrum() << std::endl;
img.display("Input image");
img.save_bmp(strFileOutput.c_str());
return 0;
}
Advertisements

One thought on “CImg: hello world

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s