Image::GetPropertyItem method (gdiplusheaders.h)
The Image::GetPropertyItem method gets a specified property item (piece of metadata) from this Image object.
Syntax
Status GetPropertyItem(
[in] PROPID propId,
[in] UINT propSize,
[out] PropertyItem *buffer
);
Parameters
[in] propId
Type: PROPID
Integer that identifies the property item to be retrieved.
[in] propSize
Type: UINT
Integer that specifies the size, in bytes, of the property item to be retrieved. Call the Image::GetPropertyItemSize method to determine the size.
[out] buffer
Type: PropertyItem*
Pointer to a PropertyItem object that receives the property item.
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.
Remarks
The Image::GetPropertyItem method returns a PropertyItem object. Before you call Image::GetPropertyItem, you must allocate a buffer large enough to receive that object — the size varies according to data type and value of the property item. You can call the Image::GetPropertyItemSize method of an Image object to get the size, in bytes, of the required buffer.
Examples
The following example creates an Image object based on a JPEG file. The code gets the make of the camera that captured the image by passing the PropertyTagEquipMake constant to the Image::GetPropertyItem method of the Image object.
#include <windows.h>
#include <gdiplus.h>
#include <stdio.h>
using namespace Gdiplus;
INT main()
{
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
UINT size = 0;
PropertyItem* propertyItem = NULL;
Image* image = new Image(L"FakePhoto.jpg");
// Assume that the image has a property item of type PropertyItemEquipMake.
// Get the size of that property item.
size = image->GetPropertyItemSize(PropertyTagEquipMake);
// Allocate a buffer to receive the property item.
propertyItem = (PropertyItem*)malloc(size);
// Get the property item.
image->GetPropertyItem(PropertyTagEquipMake, size, propertyItem);
// Display the members of the retrieved PropertyItem object.
printf("The length of the property item is %u.\n", propertyItem->length);
printf("The data type of the property item is %u.\n", propertyItem->type);
if(propertyItem->type == PropertyTagTypeASCII)
printf("The value of the property item is %s.\n", propertyItem->value);
free(propertyItem);
delete image;
GdiplusShutdown(gdiplusToken);
return 0;
}
The preceding code, along with a particular file, FakePhoto.jpg, produced the following output. Note that the data type is 2, the value of the PropertyTagTypeASCII constant that is defined in Gdiplusimaging.h.
The length of the property item is 17.
The data type of the property item is 2.
The value of the property item is Northwind Traders.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows XP, Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | gdiplusheaders.h (include Gdiplus.h) |
Library | Gdiplus.lib |
DLL | Gdiplus.dll |