CImage::Save

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.

    Note

    For a complete list of constants, see Image File Format Constants in the Windows SDK.

Return Value

A standard HRESULT.

Remarks

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.

Example:

// Demonstrating saving various file formats 
// save an image in BMP format
m_myImage.Save(_T("c:\\temp\\image1.bmp"));
// save an image in BMP format
m_myImage.Save(_T("c:\\temp\\image2"), Gdiplus::ImageFormatBMP);
// save an image in JPEG format
m_myImage.Save(_T("c:\\temp\\image3.jpg"));
// save an image in BMP format, even though jpg file extension is used
m_myImage.Save(_T("c:\\temp\\image4.jpg"), Gdiplus::ImageFormatBMP);

Requirements

Header: atlimage.h

See Also

Reference

CImage Class

CImage::Load

Other Resources

CImage Members