I have followed the CImg tutorial and I it works perfectly. However, if I try to load a different image (other than lena.jpg), I get a stack overflow error.
For example, this works:
CImg<float> image;
string filePath = "C:/Users/zzz/Documents/lena.jpg";
image.load(filePath.c_str());
But this gives an error:
CImg<float> image;
string filePath = "C:/Users/zzz/Documents/anotherimage.jpg";
image.load(filePath.c_str());
The error is: Unhandled exception at 0x77bb15de in LoadImageTest.exe: 0xC00000FD: Stack overflow.
I thought the stack overflow was due to "anotherimage.jpg" being too large, so I also tried a really small image (16x16 pixels). This resulted in the same error.
Does anyone have any suggestions as to why this is happening?
Full code:
#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;
}