[英]CImg reading image exception
我正在使用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);
處拋出CImg<unsigned char> image(fileName);
嘗試加載圖像時。 圖像在那里,所以我想知道我在哪里弄亂了,以及如何閱讀圖像?
您需要libpng或imagemagick才能使用CImg
加載PNG文件。
要本地讀取.jpeg或.png文件,CImg需要您將代碼與libpng或libjpeg鏈接,並定義宏cimg_use_png
或cimg_use_jpeg
。 這樣,根本不需要ImageMagick。 我更喜歡這種解決方案,因為它不需要安裝新的(外部)軟件來讀取圖像文件,並且還簡化了二進制文件的分發。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.