使用CImg加载PNG [英] Loading PNGs with CImg

查看:142
本文介绍了使用CImg加载PNG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用CImg加载PNG.我听说您需要首先获取libpng/zlib才能开始工作,但是我不确定如何设置它.我在Ubuntu上.我的来源:

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;
}

推荐答案

关闭,但您需要#define cimg_use_png

并将-lpng添加到链接器标志中.

and add -lpng to your linker flags.

这篇关于使用CImg加载PNG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆