Image.SaveAdd(const EncoderParameters*) method

Applies to: desktop apps only

The Image::SaveAdd method adds a frame to a file or stream specified in a previous call to the Save method. Use this method to save selected frames from a multiple-frame image to another multiple-frame image.


Status SaveAdd(
  [in]  const EncoderParameters* encoderParams


  • encoderParams [in]
    Type: const EncoderParameters*

    Pointer to an EncoderParameters object that holds parameters required by the image encoder used by the save-add operation.

Return value


Type: Status****

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

If the method fails, it returns one of the other elements of the Status enumeration.


The following example creates an Image object based on a TIFF file that has four frames. The code calls the Image::SelectActiveFrame method to navigate to the second frame in the page dimension of that Image object. (The page dimension is the only dimension in this case.) Then the code calls the Save method to save the second frame to a new file named TwoFrames.tif. The code calls the Image::SelectActiveFrame method again to navigate to the fourth frame of the Image object. Then the code calls the Image::SaveAdd method to add the fourth frame to TwoFrames.tif. The code calls the Image::SaveAdd method a second time to close TwoFrames.tif, and then draws the two frames that were saved in that file.

VOID Example_SaveAdd(HDC hdc)
   Graphics graphics(hdc);
   EncoderParameters encoderParameters;
   ULONG parameterValue;
   GUID dimension = FrameDimensionPage;

   // An EncoderParameters object has an array of
   // EncoderParameter objects. In this case, there is only
   // one EncoderParameter object in the array.
   encoderParameters.Count = 1;

   // Initialize the one EncoderParameter object.
   encoderParameters.Parameter[0].Guid = EncoderSaveFlag;
   encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
   encoderParameters.Parameter[0].NumberOfValues = 1;
   encoderParameters.Parameter[0].Value = &parameterValue;

   // Get the CLSID of the TIFF encoder.
   CLSID encoderClsid;
   GetEncoderClsid(L"image/tiff", &encoderClsid);

   // Create an image object based on a TIFF file that has four frames.
   Image fourFrames(L"FourFrames.tif");

   // Save the second page (frame).
   parameterValue = EncoderValueMultiFrame;
   fourFrames.SelectActiveFrame(&dimension, 1);
   fourFrames.Save(L"TwoFrames.tif", &encoderClsid, &encoderParameters);

   // Save the fourth page (frame).
   parameterValue = EncoderValueFrameDimensionPage;
   fourFrames.SelectActiveFrame(&dimension, 3);

   // Close the multiframe file.
   parameterValue = EncoderValueFlush;

   // Draw the two frames of TwoFrames.tif.
   Image twoFrames(L"TwoFrames.tif");
   twoFrames.SelectActiveFrame(&dimension, 0);
   graphics.DrawImage(&twoFrames, 10, 10);
   twoFrames.SelectActiveFrame(&dimension, 1);
   graphics.DrawImage(&twoFrames, 150, 10);


Minimum supported client

Windows XP, Windows 2000 Professional

Minimum supported server

Windows 2000 Server


GDI+ 1.0


Gdiplusheaders.h (include Gdiplus.h)





See also





Image::Save Methods

Image::SaveAdd Methods

Using Image Encoders and Decoders



Send comments about this topic to Microsoft

Build date: 3/6/2012