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

O método Image::GetPropertyItem obtém um item de propriedade especificado (parte dos metadados) deste objeto Image .

Sintaxe

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

Parâmetros

[in] propId

Tipo: PROPID

Inteiro que identifica o item de propriedade a ser recuperado.

[in] propSize

Tipo: UINT

Inteiro que especifica o tamanho, em bytes, do item de propriedade a ser recuperado. Chame o método Image::GetPropertyItemSize para determinar o tamanho.

[out] buffer

Tipo: PropertyItem*

Ponteiro para um objeto PropertyItem que recebe o item de propriedade.

Retornar valor

Tipo: Status

Se o método for bem-sucedido, ele retornará Ok, que é um elemento da enumeração Status .

Se o método falhar, ele retornará um dos outros elementos da enumeração Status .

Comentários

O método Image::GetPropertyItem retorna um objeto PropertyItem . Antes de chamar Image::GetPropertyItem, você deve alocar um buffer grande o suficiente para receber esse objeto — o tamanho varia de acordo com o tipo de dados e o valor do item de propriedade. Você pode chamar o método Image::GetPropertyItemSize de um objeto Image para obter o tamanho, em bytes, do buffer necessário.

Exemplos

O exemplo a seguir cria um objeto Image com base em um arquivo JPEG. O código obtém a marca da câmera que capturou a imagem passando a constante PropertyTagEquipMake para o método Image::GetPropertyItem do 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;
}

O código anterior, juntamente com um arquivo específico, FakePhoto.jpg, produziu a saída a seguir. Observe que o tipo de dados é 2, o valor da constante PropertyTagTypeASCII definida em 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 Valor
Cliente mínimo com suporte Windows XP, Windows 2000 Professional [somente aplicativos da área de trabalho]
Servidor mínimo com suporte Windows 2000 Server [somente aplicativos da área de trabalho]
Plataforma de Destino Windows
Cabeçalho gdiplusheaders.h (inclua Gdiplus.h)
Biblioteca Gdiplus.lib
DLL Gdiplus.dll

Confira também

Imagem

Image::GetAllPropertyItems

Image::GetPropertyCount

Image::GetPropertyIdList

Image::GetPropertyItemSize

Image::GetPropertySize

Image::RemovePropertyItem

Image::SetPropertyItem

PropertyItem

Leitura e gravação de metadados