我遵循CImg tutorial,我很完美地工作。但是,如果我嘗試加載不同的圖像(lena.jpg除外),則會出現堆棧溢出錯誤。CImg library not loading圖片
例如,這個工程:
CImg<float> image;
string filePath = "C:/Users/zzz/Documents/lena.jpg";
image.load(filePath.c_str());
但是,這給出了一個錯誤:
CImg<float> image;
string filePath = "C:/Users/zzz/Documents/anotherimage.jpg";
image.load(filePath.c_str());
的錯誤是:0xC00000FD:堆棧溢出在0x77bb15de在LoadImageTest.exe 未處理的異常。
我認爲堆棧溢出是由於「anotherimage.jpg」太大,所以我也嘗試了一個非常小的圖像(16x16像素)。這導致了相同的錯誤。
有沒有人有任何建議,爲什麼會發生這種情況?
全碼:
#include "stdafx.h"
#include <iostream>
#include "CImg.h"
using namespace cimg_library;
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
CImg<float> image;
// This works...
string filePath = "C:/Users/zzz/Pictures/lena.jpg";
// This doesn't work...
// string filePath = "C:/Users/zzz/Pictures/small.jpg";
image.load(filePath.c_str());
CImgDisplay main_disp(image, "The image");
while (!main_disp.is_closed())
{
main_disp.wait();
}
return 0;
}
你確定它是那個給出錯誤的部分嗎?你有沒有試過在調試器中運行它? –
您是否試過'「C:\\ Users \\ zzz \\ Documents \\ lena.jpg」'? – imreal
我們需要更多的代碼。我們喜歡代碼。 –