c++ - c+ + - cimg不会加载lenna图片

我正在使用vs2015,创建了一个win32 c 控制台应用程序,该应用程序提供了一个native c 应用程序。 演示代码无法正常工作,问题似乎出在加载lenna.png或lenna.jpg,

每次出现无法识别图像文件的错误


#include"CImg.h"


#include"stdafx.h"


using namespace cimg_library;



int main() {


 CImg<unsigned char> image("D:CODECimg-prjPGTDebugLenna.png"), visu(500,400,1,3,0);


 const unsigned char red[] = { 255,0,0 }, green[] = { 0,255,0 }, blue[] = { 0,0,255 };


 image.blur(2.5);


 CImgDisplay main_disp(image,"Click a point"), draw_disp(visu,"Intensity profile");


 while (!main_disp.is_closed() && !draw_disp.is_closed()) {


 main_disp.wait();


 if (main_disp.button() && main_disp.mouse_y()>=0) {


 const int y = main_disp.mouse_y();


 visu.fill(0).draw_graph(image.get_crop(0,y,0,0,image.width()-1,y,0,0),red,1,1,0,255,0);


 visu.draw_graph(image.get_crop(0,y,0,1,image.width()-1,y,0,1),green,1,1,0,255,0);


 visu.draw_graph(image.get_crop(0,y,0,2,image.width()-1,y,0,2),blue,1,1,0,255,0).display(draw_disp);


 }


 }


return 0;


}



我得到(所有输出)的错误:


Invalid Parameter -"C:UsersPeterAppDataLocalTempkY6GW46A.pnm"


'gm.exe' is not recognized as an internal or external command,


operable program or batch file.


Invalid Parameter -"C:UsersPeterAppDataLocalTempas88yC80.pnm"


'gm.exe' is not recognized as an internal or external command,


operable program or batch file.


Invalid Parameter -"C:UsersPeterAppDataLocalTempwa804U6G.pnm"


'gm.exe' is not recognized as an internal or external command,


operable program or batch file.



[CImg] * * * CImgIOException * * * [instance(0,0,0,0,00000000,non-shared)] CImg<float>::load(): Failed to recognize format of file 'Lenna.png'.



我确信lenna.png是有效的png文件(如果我将它扩展名重命名,irfranview将尝试将它重命名为png)。

时间:

如果希望CImg能够在不依赖ImageMagick的情况下加载png文件,则必须,


#define cimg_use_png 1


#include"CImg.h"



你还必须用GDI32库以及libpng和libz链接以压缩PNG 。

...