ImageItemData class (gdiplusimaging.h)
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:
Remarks
To retrieve custom metadata from an image file, call Image::GetItemData. To store custom metadata in an image file, follow these steps:
- Create and initialize an ImageItemData object.
- Create an EncoderParameters object that has an array of one or more EncoderParameter objects.
- 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.
- 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
Requirement | Value |
---|---|
Minimum supported client | Windows Vista [desktop apps only] |
Minimum supported server | Windows Server 2008 [desktop apps only] |
Target Platform | Windows |
Header | gdiplusimaging.h (include Gdiplus.h) |