Freigeben über


ImageItemData class

Applies to: desktop apps only

The ImageItemData class is used to store and retrieve custom image metadata. Windows GDI+ supports custom metadata for JPEG, PNG, and GIF image files.

ImageItemData has these types of members:

Data Members

The following table lists the members exposed by the ImageItemData object.

Data Members Type Description
Size UINT Integer that specifies the size of an ImageItemData object. Set to sizeof(ImageItemData).
Position UINT Element of the ItemDataPosition enumeration that specifies the location in an image file that a piece of custom metadata should be stored.
Desc VOID * A sequence of bytes that you create to identify a piece of custom metadata. For JPEG files, the description is one byte. For PNG files, the description is four bytes. For GIF files, the description is eleven bytes.
DescSize UINT Integer that specifies the size, in bytes, of the identifier pointed to by Desc. Set to 1 for JPEG, 4 for PNG, and 11 for GIF.
Data UINT * Pointer to a buffer that contains the metadata.
DataSize UINT Integer that specifies the size, in bytes, of the buffer pointed to by Data.
Cookie UINT Used internally by GDI+.

 

Remarks

To retrieve custom metadata from an image file, call Image::GetItemData. To store custom metadata in an image file, follow these steps:

  1. Create and initialize an ImageItemData object.
  2. Create an EncoderParameters object that has an array of one or more EncoderParameter objects.
  3. For one of the EncoderParameter objects in the array, set the Value member to the address of your ImageItemData object. Set the other members as follows: Guid = EncoderImageItems, Type = EncoderParameterValueTypePointer, NumberOfValues = 1.
  4. Pass the address of the EncoderParameters object to the Image::Save method of an Image object.

Examples

The following example saves a piece of custom metadata in a JPEG file. The code relies on a helper function, GetEncoderClsid, to get the class identifier for the JPEG encoder. To see the source code for GetEncoderClsid, see Retrieving the Class Identifier for an Encoder.

CHAR myData[] = "Byte sequence of your choice";
BYTE description = 0xE4;

ImageItemData itemData;
itemData.Size = sizeof(itemData);
itemData.DescSize = 1;
itemData.Desc = &description;
itemData.DataSize = 28;
itemData.Data = (VOID*)myData;
itemData.Position = ItemDataPositionAfterHeader;

// Get the Clsid of the JPEG encoder.
CLSID encoderClsid;
GetEncoderClsid(L"image/jpeg", &encoderClsid);

EncoderParameters encoderParameters;
encoderParameters.Count = 1;
encoderParameters.Parameter[0].Guid = EncoderImageItems;
encoderParameters.Parameter[0].Type = EncoderParameterValueTypePointer;
encoderParameters.Parameter[0].NumberOfValues = 1; 
encoderParameters.Parameter[0].Value = &itemData;

Image image(L"River.jpg");
image.Save(L"River2.jpg", &encoderClsid, &encoderParameters);

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008

Product

GDI+ 1.1

Header

Gdiplusimaging.h (include Gdiplus.h)

Library

Gdiplus.lib

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012