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

O método Image::GetPropertySize obtém o tamanho total, em bytes, de todos os itens de propriedade armazenados neste objeto Image . O método Image::GetPropertySize também obtém o número de itens de propriedade armazenados neste objeto Image .

Sintaxe

Status GetPropertySize(
  [out] UINT *totalBufferSize,
  [out] UINT *numProperties
);

Parâmetros

[out] totalBufferSize

Tipo: UINT*

Ponteiro para um UINT que recebe o tamanho total, em bytes, de todos os itens de propriedade.

[out] numProperties

Tipo: UINT*

Ponteiro para um UINT que recebe o número de itens de propriedade.

Valor retornado

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 Windows GDI+ armazena uma parte individual dos metadados em um objeto PropertyItem . O método Image::GetAllPropertyItems retorna uma matriz de objetos PropertyItem . Antes de chamar Image::GetAllPropertyItems, você deve alocar um buffer grande o suficiente para receber essa matriz. Você pode chamar o método Image::GetPropertySize de um objeto Image para obter o tamanho, em bytes, do buffer necessário. O método Image::GetPropertySize também fornece o número de propriedades (partes de metadados) na imagem.

Exemplos

O exemplo a seguir cria um objeto Image com base em um arquivo JPEG. O código chama o método Image::GetAllPropertyItems desse objeto Image para obter seus itens de propriedade (metadados).

#include <windows.h>
#include <gdiplus.h>
#include <stdio.h>
using namespace Gdiplus;

INT main()
{
   GdiplusStartupInput gdiplusStartupInput;
   ULONG_PTR gdiplusToken;
   GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

   // Create an Image object based on a JPEG file.
   Image* image = new Image(L"FakePhoto.jpg"); 

  // Find out how many property items are in the image, and find out the
   // required size of the buffer that will receive those property items.
   UINT totalBufferSize;
   UINT numProperties;
   image->GetPropertySize(&totalBufferSize, &numProperties);

   // Allocate the buffer that will receive the property items.
   PropertyItem* pAllItems = (PropertyItem*)malloc(totalBufferSize);

   // Fill the buffer.
   image->GetAllPropertyItems(totalBufferSize, numProperties, pAllItems);

   // Print the ID of each property item.
   for(UINT j = 0; j < numProperties; ++j)
   {
      printf("%x\n", pAllItems[j].id);
   }

   free(pAllItems);
   delete image;
   GdiplusShutdown(gdiplusToken);
   return 0;
}

O código anterior, juntamente com um arquivo específico, FakePhoto.jpg, produziu a seguinte saída:

320
10f
110
9003
829a
5090
5091

A saída anterior mostra o valor hexadecimal de cada identificador de propriedade. Você pode pesquisar esses números em Gdiplusimaging.h e descobrir que eles representam as marcas de propriedade a seguir.

Valor hexadecimal Marca de propriedade
0x0320 PropertyTagImageTitle
0x010f PropertyTagEquipMake
0x0110 PropertyTagEquipModel
0x9003 PropertyTagExifDTOriginal
0x829a PropertyTagExifExposturaTime
0x5090 PropertyTagLuminanceTable
0x5091 PropertyTagChrominanceTable
 

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

Image::RemovePropertyItem

Image::SetPropertyItem

PropertyItem

Leitura e gravação de metadados