使用 CImg 加载 PNG

发布于 2024-09-28 20:13:25 字数 438 浏览 0 评论 0原文

我无法使用 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;
}

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一曲琵琶半遮面シ 2024-10-05 20:13:25

关闭,但您需要 #define cimg_use_png

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

Close, but you need #define cimg_use_png

and add -lpng to your linker flags.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文