Saves an image to the specified stream or file on disk.
HRESULT Save(
IStream* pStream,
REFGUID guidFileType
) const throw();
HRESULT Save(
LPCTSTR pszFileName,
REFGUID guidFileType= GUID_NULL
) const throw();
Parameters
- 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 as. Can be one of the following:
-
ImageFormatBMP An uncompressed bitmap image.
-
ImageFormatPNG A Portable Network Graphic (PNG) compressed image.
-
ImageFormatJPEG A JPEG compressed image.
-
ImageFormatGIF A GIF compressed image.
A standard HRESULT.
Call this function to save the image using a specified name and type. If the guidFileType parameter is not included, the file name's file extension will be used to determine the image format. If no extension is provided, the image will be saved in BMP format.
// Demonstrating saving various file formats
int _tmain(int argc, _TCHAR* argv[])
{
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);
return 0;
}
See also the ShowImage Sample.
Reference
CImage Class
CImage::Load
Other Resources
CImage Members