Image ::GetPropertyItem, méthode (gdiplusheaders.h)

La méthode Image ::GetPropertyItem obtient un élément de propriété spécifié (morceau de métadonnées) à partir de cet objet Image .

Syntaxe

Status GetPropertyItem(
  [in]  PROPID       propId,
  [in]  UINT         propSize,
  [out] PropertyItem *buffer
);

Paramètres

[in] propId

Type : PROPID

Entier qui identifie l’élément de propriété à récupérer.

[in] propSize

Type : UINT

Entier qui spécifie la taille, en octets, de l’élément de propriété à récupérer. Appelez la méthode Image ::GetPropertyItemSize pour déterminer la taille.

[out] buffer

Type : PropertyItem*

Pointeur vers un objet PropertyItem qui reçoit l’élément de propriété.

Valeur retournée

Type : État

Si la méthode réussit, elle retourne Ok, qui est un élément de l’énumération Status .

Si la méthode échoue, elle retourne l’un des autres éléments de l’énumération Status .

Remarques

La méthode Image ::GetPropertyItem renvoie un objet PropertyItem . Avant d’appeler Image ::GetPropertyItem, vous devez allouer une mémoire tampon suffisamment grande pour recevoir cet objet. La taille varie en fonction du type de données et de la valeur de l’élément de propriété. Vous pouvez appeler la méthode Image ::GetPropertyItemSize d’un objet Image pour obtenir la taille, en octets, de la mémoire tampon requise.

Exemples

L’exemple suivant crée un objet Image basé sur un fichier JPEG. Le code obtient la création de la caméra qui a capturé l’image en passant la constante PropertyTagEquipMake à la méthode Image ::GetPropertyItem de l’objet Image .

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

Le code précédent, ainsi qu’un fichier particulier, FakePhoto.jpg, ont produit la sortie suivante. Notez que le type de données est 2, la valeur de la constante PropertyTagTypeASCII définie dans 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.

Configuration requise

Condition requise Valeur
Client minimal pris en charge Windows XP, Windows 2000 Professionnel [applications de bureau uniquement]
Serveur minimal pris en charge Windows 2000 Server [applications de bureau uniquement]
Plateforme cible Windows
En-tête gdiplusheaders.h (inclure Gdiplus.h)
Bibliothèque Gdiplus.lib
DLL Gdiplus.dll

Voir aussi

Image

Image ::GetAllPropertyItems

Image ::GetPropertyCount

Image ::GetPropertyIdList

Image ::GetPropertyItemSize

Image ::GetPropertySize

Image ::RemovePropertyItem

Image ::SetPropertyItem

PropertyItem

Lecture et écriture de métadonnées