Reputation: 2260
I'm using vs2015, created a win32 c++ console app This gives a pure native c++ app, while i got some other examples working. This demo code doesn't work, the problem seams to the loading of the lenna.png or lenna.jpg
Each time i get errors that the image file isn't recognized. ( i even used the original lenna as from wikipedia) but it doesn't work for some unknown reason, to exclude path problems i even placed lenna at "d:\\lenna.jpg" as well.
I don't know why it won't work, any ideas?
Is cimg just old and doesn't recognize jpg of these days ??
#include "CImg.h"
#include "stdafx.h"
using namespace cimg_library;
int main() {
CImg<unsigned char> image("D:\\CODE\\Cimg-prj\\PGT\\Debug\\Lenna.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;
}
The errors i get (all output) :
Invalid Parameter - "C:\\Users\\Peter\\AppData\\Local\\Temp\\kY6GW46A.pnm"
'gm.exe' is not recognized as an internal or external command,
operable program or batch file.
Invalid Parameter - "C:\\Users\\Peter\\AppData\\Local\\Temp\\as88yC80.pnm"
'gm.exe' is not recognized as an internal or external command,
operable program or batch file.
Invalid Parameter - "C:\\Users\\Peter\\AppData\\Local\\Temp\\wa804U6G.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'.
I am sure Lenna.png is a valid png file (if i rename its extension irfranview will try to rename it back as png).
I might not get it to work due to the extra complexity of setting up a project properly for png, i downloaded zlib and libpng, but not sure how to add them to the project (and their a bunch of files?, their not a single dll or .h file like cimg do i need to add all those files ???)
Upvotes: -2
Views: 507
Reputation: 207485
If you want CImg to be able to load PNG files without relying on ImageMagick, you must tell it so by defining a macro before loading the CImg header file;
#define cimg_use_png 1
#include "CImg.h"
You must also link with library GDI32 and libpng and libz for compression of PNGs.
Upvotes: 0