Share via


Metodo Image::GetAllPropertyItems (gdiplusheaders.h)

Il metodo Image::GetAllPropertyItems ottiene tutti gli elementi della proprietà (metadati) archiviati in questo oggetto Image .

Sintassi

Status GetAllPropertyItems(
  [in]  UINT         totalBufferSize,
  [in]  UINT         numProperties,
  [out] PropertyItem *allItems
);

Parametri

[in] totalBufferSize

Tipo: UINT

Intero che specifica le dimensioni, in byte, del buffer allItems . Chiamare il metodo Image::GetPropertySize per ottenere le dimensioni necessarie.

[in] numProperties

Tipo: UINT

Intero che specifica il numero di proprietà nell'immagine. Chiamare il metodo Image::GetPropertySize per ottenere questo numero.

[out] allItems

Tipo: PropertyItem*

Puntatore a una matrice di oggetti PropertyItem che riceve gli elementi della proprietà.

Valore restituito

Tipo: Stato

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

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

Commenti

Alcuni file di immagine contengono metadati che è possibile leggere per determinare le funzionalità dell'immagine. Ad esempio, una fotografia digitale può contenere metadati che è possibile leggere per determinare la creazione e il modello della fotocamera usata per acquisire l'immagine.

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 sufficientemente grande per ricevere tale matrice. È possibile chiamare il metodo Image::GetPropertySize di un oggetto Image per ottenere le dimensioni, in byte, del buffer necessario. Il metodo Image::GetPropertySize fornisce anche il numero di proprietà (parti di metadati) nell'immagine.

Diverse enumerazioni e costanti correlate ai metadati dell'immagine sono definite in Gdiplusimaging.h.

Esempio

Nell'esempio seguente viene creato un oggetto Image basato su un file JPEG. Il codice chiama il metodo GetAllPropertyItemsdell'oggetto Image per ottenere gli elementi della 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 data member 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 particolare file, FakePhoto.jpg, ha prodotto l'output seguente:

320
10f
110
9003
829a
5090
5091

L'output precedente mostra un numero ID esadecimale per ogni elemento della proprietà. È possibile cercare i numeri ID in Gdiplusimaging.h e scoprire che rappresentano i tag di 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::GetPropertyCount

Image::GetPropertyIdList

Image::GetPropertyItem

Image::GetPropertyItemSize

Image::GetPropertySize

Image::RemovePropertyItem

Image::SetPropertyItem

PropertyItem

Lettura e scrittura di metadati