Image::GetAllPropertyItems メソッド (gdiplusheaders.h)

Image::GetAllPropertyItems メソッドは、この Image オブジェクトに格納されているすべてのプロパティ項目 (メタデータ) 取得します。

構文

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

パラメーター

[in] totalBufferSize

型: UINT

allItems バッファーのサイズをバイト単位で指定する整数。 Image::GetPropertySize メソッドを呼び出して、必要なサイズを取得します。

[in] numProperties

型: UINT

イメージ内のプロパティの数を指定する整数。 この番号を取得するには、 Image::GetPropertySize メソッドを呼び出します。

[out] allItems

Type: PropertyItem*

プロパティ項目を受け取る PropertyItem オブジェクトの配列へのポインター。

戻り値

種類: 状態

メソッドが成功した場合は、 Status 列挙の要素である Ok を返します。

メソッドが失敗した場合は、 Status 列挙体の他の要素のいずれかを返します。

解説

一部の画像ファイルにはメタデータが含まれており、これを読み取って画像の特徴を判断することができます。 たとえば、デジタル写真には、画像の撮影に使用されたカメラのメーカーとモデルを読み取って判別できるメタデータが含まれている場合があります。

GDI+ は、個別のメタデータを PropertyItem オブジェクトに格納します。 Image::GetAllPropertyItems メソッドは PropertyItem オブジェクトの配列を返します。 Image::GetAllPropertyItems を呼び出す前に、その配列を受け取るのに十分な大きさのバッファーを割り当てる必要があります。 Image オブジェクトの Image::GetPropertySize メソッドを呼び出して、必要なバッファーのサイズをバイト単位で取得できます。 Image::GetPropertySize メソッドは、画像内のプロパティ (メタデータの一部) の数も提供します。

Gdiplusimaging.h では、画像メタデータに関連するいくつかの列挙と定数が定義されています。

次の例では、JPEG ファイルに基づいて Image オブジェクトを作成します。 このコードでは、その Image オブジェクトの GetAllPropertyItems メソッドを呼び出して、そのプロパティ項目 (メタデータ) を取得します。

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

上記のコードは、特定のファイルと共に FakePhoto.jpg、次の出力を生成しました。

320
10f
110
9003
829a
5090
5091

上記の出力は、各プロパティ項目の 16 進数の ID 番号を示しています。 Gdiplusimaging.h でこれらの ID 番号を調べて、次のプロパティ タグを表していることを確認できます。

16 進数値 プロパティ タグ
0x0320 PropertyTagImageTitle
0x010f PropertyTagEquipMake
0x0110 PropertyTagEquipModel
0x9003 PropertyTagExifDTOriginal
0x829a PropertyTagExifExposureTime
0x5090 PropertyTagLuminanceTable
0x5091 PropertyTagChrominanceTable
 

要件

   
サポートされている最小のクライアント Windows XP、Windows 2000 Professional [デスクトップ アプリのみ]
サポートされている最小のサーバー Windows 2000 Server [デスクトップ アプリのみ]
対象プラットフォーム Windows
ヘッダー gdiplusheaders.h (Gdiplus.h を含む)
Library Gdiplus.lib
[DLL] Gdiplus.dll

関連項目

イメージ

Image::GetPropertyCount

Image::GetPropertyIdList

Image::GetPropertyItem

Image::GetPropertyItemSize

Image::GetPropertySize

Image::RemovePropertyItem

Image::SetPropertyItem

PropertyItem

メタデータの読み取りと書き込み