Метод Image::GetPropertyItem (gdiplusheaders.h)

Метод Image::GetPropertyItem получает указанный элемент свойства (часть метаданных) из этого объекта Image .

Синтаксис

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

Параметры

[in] propId

Тип: PROPID

Целое число, определяющее извлекаемый элемент свойства.

[in] propSize

Тип: UINT

Целое число, указывающее размер извлекаемого элемента свойства (в байтах). Вызовите метод Image::GetPropertyItemSize , чтобы определить размер.

[out] buffer

Тип: PropertyItem*

Указатель на объект PropertyItem , который получает элемент свойства.

Возвращаемое значение

Тип: Состояние

В случае успешного выполнения метода возвращается ОК, который является элементом перечисления Status .

Если метод завершается сбоем, он возвращает один из других элементов перечисления Status .

Комментарии

Метод Image::GetPropertyItem возвращает объект PropertyItem . Перед вызовом Image::GetPropertyItem необходимо выделить буфер, достаточно большой для получения этого объекта. Размер зависит от типа данных и значения элемента свойства. Вы можете вызвать метод Image::GetPropertyItemSize объекта Image , чтобы получить размер необходимого буфера в байтах.

Примеры

В следующем примере создается объект Image на основе JPEG-файла. Код получает элемент камеры, захватив изображение, передав константу PropertyTagEquipMake методу Image::GetPropertyItem объекта 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;
}

Приведенный выше код вместе с определенным файлом FakePhoto.jpg выводятся следующие выходные данные. Обратите внимание, что тип данных — 2, значение константы PropertyTagTypeASCII, определенной в 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.

Требования

Требование Значение
Минимальная версия клиента Windows XP, Windows 2000 Professional [только классические приложения]
Минимальная версия сервера Windows 2000 Server [только классические приложения]
Целевая платформа Windows
Header gdiplusheaders.h (включая Gdiplus.h)
Библиотека Gdiplus.lib
DLL Gdiplus.dll

См. также раздел

Изображение

Image::GetAllPropertyItems

Image::GetPropertyCount

Image::GetPropertyIdList

Image::GetPropertyItemSize

Image::GetPropertySize

Image::RemovePropertyItem

Image::SetPropertyItem

PropertyItem

Чтение и запись метаданных