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

El método Image::GetPropertySize obtiene el tamaño total, en bytes, de todos los elementos de propiedad almacenados en este objeto Image . El método Image::GetPropertySize también obtiene el número de elementos de propiedad almacenados en este objeto Image .

Sintaxis

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

Parámetros

[out] totalBufferSize

Tipo: UINT*

Puntero a un UINT que recibe el tamaño total, en bytes, de todos los elementos de propiedad.

[out] numProperties

Tipo: UINT*

Puntero a un UINT que recibe el número de elementos 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

GDI+ de Windows almacena un fragmento individual de metadatos en un objeto PropertyItem . El método Image::GetAllPropertyItems devuelve una matriz de objetos PropertyItem . Antes de llamar a Image::GetAllPropertyItems, debe asignar un búfer lo suficientemente grande como para recibir esa matriz. Puede llamar al método Image::GetPropertySize de un objeto Image para obtener el tamaño, en bytes, del búfer necesario. El método Image::GetPropertySize también proporciona el número de propiedades (fragmentos de metadatos) de la imagen.

Ejemplos

En el ejemplo siguiente se crea un objeto Image basado en un archivo JPEG. El código llama al método Image::GetAllPropertyItems de ese objeto Image para obtener sus elementos de propiedad (metadatos).

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

El código anterior, junto con un archivo determinado, FakePhoto.jpg, produjo la siguiente salida:

320
10f
110
9003
829a
5090
5091

La salida anterior muestra el valor hexadecimal de cada identificador de propiedad. Puede buscar esos números en Gdiplusimaging.h y averiguar que representan las siguientes etiquetas de propiedad.

Valor hexadecimal Etiqueta de propiedad
0x0320 PropertyTagImageTitle
0x010f PropertyTagEquipMake
0x0110 PropertyTagEquipModel
0x9003 PropertyTagExifDTOriginal
0x829a PropertyTagExifExposureTime
0x5090 PropertyTagLuminanceTable
0x5091 PropertyTagChrominanceTable
 

Requisitos

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

Image::GetPropertyItemSize

Image::RemovePropertyItem

Image::SetPropertyItem

PropertyItem

Lectura y escritura de metadatos