Share via


Metodo Image::GetPropertyItemSize (gdiplusheaders.h)

Il metodo Image::GetPropertyItemSize ottiene le dimensioni, in byte, di un elemento di proprietà specificato di questo oggetto Image .

Sintassi

UINT GetPropertyItemSize(
  [in] PROPID propId
);

Parametri

[in] propId

Tipo: PROPID

Intero che identifica l'elemento della proprietà.

Valore restituito

Tipo: UINT

Questo metodo restituisce le dimensioni, in byte, di un elemento di proprietà specificato di questo oggetto Image .

Commenti

Il metodo Image::GetPropertyItem restituisce un oggetto PropertyItem . Prima di chiamare Image::GetPropertyItem, è necessario allocare un buffer abbastanza grande per ricevere tale oggetto: le dimensioni variano in base al tipo di dati e al valore dell'elemento della proprietà. È possibile chiamare il metodo Image::GetPropertyItemSize di un oggetto Image per ottenere le dimensioni, in byte, del buffer richiesto.

Esempio

Nell'esempio seguente viene creato un oggetto Image basato su un file JPEG. Il codice chiama il metodo Image::GetPropertyItemSize dell'oggetto Image per ottenere le dimensioni dell'elemento della proprietà che contiene il make della fotocamera usata per acquisire l'immagine. Il codice chiama quindi il metodo Image::GetPropertyItem per recuperare tale elemento di proprietà.

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

Il codice precedente, insieme a un determinato file, FakePhoto.jpg, ha prodotto l'output seguente. Si noti che il tipo di dati è 2, ovvero il valore della costante PropertyTagTypeASCII definita in 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.

Requisiti

   
Client minimo supportato Windows XP, Windows 2000 Professional [solo app desktop]
Server minimo supportato Windows 2000 Server [solo app desktop]
Piattaforma di destinazione Windows
Intestazione gdiplusheaders.h (include Gdiplus.h)
Libreria Gdiplus.lib
DLL Gdiplus.dll

Vedi anche

Immagine

Image::GetAllPropertyItems

Image::GetPropertyCount

Image::GetPropertyIdList

Image::GetPropertyItem

Image::GetPropertySize

Image::RemovePropertyItem

Image::SetPropertyItem

PropertyItem

Lettura e scrittura di metadati