Share via


Metodo Image::GetPropertySize (gdiplusheaders.h)

Il metodo Image::GetPropertySize ottiene le dimensioni totali, in byte, di tutti gli elementi delle proprietà archiviati in questo oggetto Image . Il metodo Image::GetPropertySize ottiene anche il numero di elementi delle proprietà archiviati in questo oggetto Image .

Sintassi

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

Parametri

[out] totalBufferSize

Tipo: UINT*

Puntatore a un oggetto UINT che riceve le dimensioni totali, in byte, di tutti gli elementi della proprietà.

[out] numProperties

Tipo: UINT*

Puntatore a un oggetto UINT che riceve il numero di elementi della proprietà.

Valore restituito

Tipo: Stato

Se il metodo ha esito positivo, restituisce Ok, ovvero un elemento dell'enumerazione Status .

Se il metodo ha esito negativo, restituisce uno degli altri elementi dell'enumerazione Status .

Commenti

Windows GDI+ archivia una singola parte di metadati in un oggetto PropertyItem . Il metodo Image::GetAllPropertyItems restituisce una matrice di oggetti PropertyItem . Prima di chiamare Image::GetAllPropertyItems, è necessario allocare un buffer abbastanza grande per ricevere tale matrice. È possibile chiamare il metodo Image::GetPropertySize di un oggetto Image per ottenere le dimensioni, in byte, del buffer richiesto. Il metodo Image::GetPropertySize offre anche il numero di proprietà (parti di metadati) nell'immagine.

Esempio

Nell'esempio seguente viene creato un oggetto Image basato su un file JPEG. Il codice chiama il metodo Image::GetAllPropertyItems dell'oggetto Image per ottenere i relativi elementi di proprietà (metadati).

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

Il codice precedente, insieme a un determinato file, FakePhoto.jpg, ha prodotto l'output seguente:

320
10f
110
9003
829a
5090
5091

L'output precedente mostra il valore esadecimale di ogni identificatore di proprietà. È possibile cercare questi numeri in Gdiplusimaging.h e scoprire che rappresentano i tag delle proprietà seguenti.

Valore esadecimale Tag proprietà
0x0320 PropertyTagImageTitle
0x010f PropertyTagEquipMake
0x0110 PropertyTagEquipModel
0x9003 PropertyTagExifDTOriginal
0x829a PropertyTagExifExposureTime
0x5090 PropertyTagLuminanceTable
0x5091 PropertyTagChrominanceTable
 

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

Image::RemovePropertyItem

Image::SetPropertyItem

PropertyItem

Lettura e scrittura di metadati