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

El método Image::GetPropertyItemSize obtiene el tamaño, en bytes, de un elemento de propiedad especificado de este objeto Image .

Sintaxis

UINT GetPropertyItemSize(
  [in] PROPID propId
);

Parámetros

[in] propId

Tipo: PROPID

Entero que identifica el elemento de propiedad.

Valor devuelto

Tipo: UINT

Este método devuelve el tamaño, en bytes, de un elemento de propiedad especificado de este objeto Image .

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 llama al método Image::GetPropertyItemSize de ese objeto Image para obtener el tamaño del elemento de propiedad que contiene la marca de la cámara utilizada para capturar la imagen. A continuación, el código llama al método Image::GetPropertyItem para recuperar ese elemento de propiedad.

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

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

Image::RemovePropertyItem

Image::SetPropertyItem

PropertyItem

Lectura y escritura de metadatos