使用CImg加载PNG

yxk*_*yxk 5 png zlib cimg libpng

我无法使用CImg加载PNG.我听说你需要让libpng/zlib先上班,但我不确定如何设置它.我在Ubuntu上.我的来源:

#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;
}
Run Code Online (Sandbox Code Playgroud)

Mee*_*ohi 7

关闭,但你需要 #define cimg_use_png

并添加-lpng到您的链接器标志.