For Sharing the CImage With MFC, We need to include the header file,
#include "atlimage.h"
#include "atltypes.h" (Optional)
Load Image in to CImage
To load an image to the CImage two formats are available,
1.HRESULT Load(LPCTSTR pszFileName);
Where,
2.HRESULT Load(IStream* pStream);
Where,
Example:
CImage img;
img.Load("C:\images\sample.tiff");
Save Image From CImage
To Save an image in CImage two formats available,
1.HRESULT Save(IStream* pStream,REFGUID guidFileType);
2.HRESULT Save(LPCTSTR pszFileName,REFGUID guidFileType= GUID_NULL);
where,
- pStream -- A pointer to a COM IStream object containing the file image data.
- pszFileName -- A pointer to the file name for the image.
- guidFileType -- The file type to save the image .
- Example:
- img.Save("D:\\images.bmp");