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

O método Image::GetPropertyItemSize obtém o tamanho, em bytes, de um item de propriedade especificado deste objeto Image .

Sintaxe

UINT GetPropertyItemSize(
  [in] PROPID propId
);

Parâmetros

[in] propId

Tipo: PROPID

Inteiro que identifica o item de propriedade.

Valor retornado

Tipo: UINT

Esse método retorna o tamanho, em bytes, de um item de propriedade especificado deste objeto Image .

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 chama o método Image::GetPropertyItemSize desse objeto Image para obter o tamanho do item de propriedade que contém a marca da câmera usada para capturar a imagem. Em seguida, o código chama o método Image::GetPropertyItem para recuperar esse item de propriedade.

#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, que é 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

   
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::GetPropertyItem

Image::GetPropertySize

Image::RemovePropertyItem

Image::SetPropertyItem

PropertyItem

Leitura e gravação de metadados