Last active
March 12, 2017 11:44
-
-
Save huklee/8d23a01e419c833ea75353ee9a9649dc to your computer and use it in GitHub Desktop.
cImg simple read & display a file example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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