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

La méthode Image::GetPropertyItemSize obtient la taille, en octets, d’un élément de propriété spécifié de cet objet Image .

Syntaxe

UINT GetPropertyItemSize(
  [in] PROPID propId
);

Paramètres

[in] propId

Type : PROPID

Entier qui identifie l’élément de propriété.

Valeur retournée

Type : UINT

Cette méthode retourne la taille, en octets, d’un élément de propriété spécifié de cet objet Image .

Notes

La méthode Image::GetPropertyItem retourne 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 appelle la méthode Image::GetPropertyItemSize de cet objet Image pour obtenir la taille de l’élément de propriété qui contient la création de la caméra utilisée pour capturer l’image. Ensuite, le code appelle la méthode Image::GetPropertyItem pour récupérer cet élément de propriété.

#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, qui est 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

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

Image::GetPropertySize

Image::RemovePropertyItem

Image::SetPropertyItem

PropertyItem

Lecture et écriture de métadonnées