Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Visual C++
ATL/MFC
CImage Class
CImage Methods
 CImage::Save
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Shared Visual C++ Classes Reference
CImage::Save

Updated: November 2007

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();
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.

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.

Visual C++
// 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);

Header: atlimage.h

Reference

Other Resources

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker