mfcvisual-c++-2005

Unable to get CImage to work in Visual C++ 2005 (MFC)


I am using an example from MSDN, but I get "'CImage' : undeclared identifier"?

CImage myimage;
   // load existing image
   myimage.Load("image.bmp"); 
      // save an image in BMP format
   myimage.Save("c:\image1.bmp");
   // save an image in BMP format
   myimage.Save("c:\image2",ImageFormatBMP);
   // save an image in JPEG format
   myimage.Save("c:\image3.jpg");
   // save an image in BMP format, even though jpg file extension is used
   myimage.Save("c:\image4.jpg",ImageFormatBMP);

Solution

  • The documentation for CImage shows that it is defined in atlimage.h. You must #include that in your source. Also note the warning that you must include afxstr.h first to avoid errors.