Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Image.GetPropertyItem method

Applies to: desktop apps only

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

propId [in]

Type: PROPID

Integer that identifies the property item to be retrieved.

propSize [in]

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.

buffer [out]

Type: PropertyItem*

Pointer to a PropertyItem object that receives the property item.

Return value

Type:

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

Minimum supported client

Windows XP, Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Product

GDI+ 1.0

Header

Gdiplusheaders.h (include Gdiplus.h)

Library

Gdiplus.lib

DLL

Gdiplus.dll

See also

Image
Image::GetAllPropertyItems
Image::GetPropertyCount
Image::GetPropertyIdList
Image::GetPropertyItemSize
Image::GetPropertySize
PropertyItem
Image::RemovePropertyItem
Image::SetPropertyItem
Reading and Writing Metadata

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions

Show:
© 2014 Microsoft