Método Image::GetPropertyItem (gdiplusheaders.h)

El método Image::GetPropertyItem obtiene un elemento de propiedad especificado (fragmento de metadatos) de este objeto Image .

Sintaxis

Status GetPropertyItem(
  [in]  PROPID       propId,
  [in]  UINT         propSize,
  [out] PropertyItem *buffer
);

Parámetros

[in] propId

Tipo: PROPID

Entero que identifica el elemento de propiedad que se va a recuperar.

[in] propSize

Tipo: UINT

Entero que especifica el tamaño, en bytes, del elemento de propiedad que se va a recuperar. Llame al método Image::GetPropertyItemSize para determinar el tamaño.

[out] buffer

Tipo: PropertyItem*

Puntero a un objeto PropertyItem que recibe el elemento de propiedad.

Valor devuelto

Tipo: Estado

Si el método se realiza correctamente, devuelve Ok, que es un elemento de la enumeración Status .

Si se produce un error en el método, devuelve uno de los otros elementos de la enumeración Status .

Comentarios

El método Image::GetPropertyItem devuelve un objeto PropertyItem . Antes de llamar a Image::GetPropertyItem, debe asignar un búfer lo suficientemente grande para recibir ese objeto, el tamaño varía según el tipo de datos y el valor del elemento de propiedad. Puede llamar al método Image::GetPropertyItemSize de un objeto Image para obtener el tamaño, en bytes, del búfer necesario.

Ejemplos

En el ejemplo siguiente se crea un objeto Image basado en un archivo JPEG. El código obtiene la marca de la cámara que capturó la imagen pasando la constante PropertyTagEquipMake al método Image::GetPropertyItem del objeto Image .

#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;
}

El código anterior, junto con un archivo determinado, FakePhoto.jpg, produjo la siguiente salida. Tenga en cuenta que el tipo de datos es 2, el valor de la constante PropertyTagTypeASCII que se define en 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.

Requisitos

Requisito Value
Cliente mínimo compatible Windows XP, Windows 2000 Professional [solo aplicaciones de escritorio]
Servidor mínimo compatible Windows 2000 Server [solo aplicaciones de escritorio]
Plataforma de destino Windows
Encabezado gdiplusheaders.h (include Gdiplus.h)
Library Gdiplus.lib
Archivo DLL Gdiplus.dll

Consulte también

Imagen

Image::GetAllPropertyItems

Image::GetPropertyCount

Image::GetPropertyIdList

Image::GetPropertyItemSize

Image::GetPropertySize

Image::RemovePropertyItem

Image::SetPropertyItem

PropertyItem

Lectura y escritura de metadatos