我遵循了CImg tutorial,我发现它工作得很好。
例如,这是可行的:
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());我认为堆栈溢出是由于"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;
}发布于 2013-01-10 16:27:39
看起来很奇怪。你确定这确实是一个JPG格式的文件吗?它是否使用一些特殊的JPEG格式(黑白,12位?,...)。
https://stackoverflow.com/questions/14242983
复制相似问题