Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual C++
Reference
Libraries Reference
ATL/MFC
CImage Class
Methods
 CImage::Save
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
Shared Visual C++ Classes Reference 
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.

NoteNote

For a complete list of constants, see Image File Format Constants in the Platform 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.

// 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

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