我使用CImg读取.png文件,如下所示:
// DGT.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include "..\CImg\CImg.h"
using namespace std;
using namespace cimg_library;
long ReadImage(char *fileName)
{
CImg<unsigned char> image(fileName); // stackover flow exceptions thrown here.
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
ReadImage("D:\\Projects\\DGT\\DGT\\shepplogan256.png");
return 0;
}但是,当试图加载映像时,堆栈溢出的异常将抛出到CImg<unsigned char> image(fileName);。图像在那里,所以我想知道我在哪里搞砸了,以及如何读取图像?
发布于 2014-09-25 20:19:16
您需要利布平或影象来加载带有CImg的PNG文件。
发布于 2014-09-25 20:53:41
要本机读取.jpeg或.png文件,CImg需要将代码链接到libpng或libjpeg,并定义宏cimg_use_png或cimg_use_jpeg。这样做,根本不需要ImageMagick。我更喜欢这个解决方案,因为它不需要安装一个新的(外部)软件来读取图像文件,并且也简化了二进制文件的分发。
https://stackoverflow.com/questions/26046581
复制相似问题