Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading PNGs with CImg

I am unable to load PNGs with CImg. I've heard you need to get libpng / zlib to get to work first but I am unsure how to set this up. I am on Ubuntu. My source:

#include <cmath>
#include <cstdio>
#include <string>
#include <assert.h>
#include <stdarg.h>

#define cimg_using_png
#include "CImg.h"
using namespace cimg_library;
#include "png.h"

int main(int argc, char** argv)
{
    CImg<unsigned char> img2("test.png");
    img2.display();
    return 0;
}
like image 671
Venus Avatar asked Oct 23 '10 00:10

Venus


1 Answers

Close, but you need #define cimg_use_png

and add -lpng to your linker flags.

like image 107
Meekohi Avatar answered Sep 21 '22 23:09

Meekohi