Skip to content

Instantly share code, notes, and snippets.

@huklee
Last active March 12, 2017 11:44
Show Gist options
  • Save huklee/8d23a01e419c833ea75353ee9a9649dc to your computer and use it in GitHub Desktop.
Save huklee/8d23a01e419c833ea75353ee9a9649dc to your computer and use it in GitHub Desktop.
cImg simple read & display a file example
#ifndef cimg_plugin
#define cimg_plugin " "
#include "CImg.h"
using namespace cimg_library;
#ifndef cimg_imagepath
#define cimg_imagepath "img/"
#endif
#include <string>
#include <iostream>
// Main procedure
//----------------
int main(int argc, char* argv[]) {
CImg<short> img1;
if (argc == 2){
std::string s(cimg_imagepath);
s.append (argv[1]);
std::cout << "load : " << s << std::endl;
img1 = CImg<short>(s.c_str());
}
else
img1 = CImg<short>(cimg_imagepath "simple.png");
const float default_color[] = { 30,30,80 };
// Modify 'img1' using the RGB pixel accessor.
// cimg_forXY(img1,x,y)
// if (!((x*y)%31)) img1.RGB_at(x,y) = default_color;
// else if ((x+y)%2) img1.RGB_at(x,y) = img2.RGB_at(x,y);
img1.display();
// Quit.
return 0;
}
#else
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment