Image::GetPropertyItem メソッドは、この Image オブジェクトから指定されたプロパティ項目 (メタデータの一部) を取得します。
構文
Status GetPropertyItem(
[in] PROPID propId,
[in] UINT propSize,
[out] PropertyItem *buffer
);
パラメーター
[in] propId
型: PROPID
取得するプロパティ項目を識別する整数。
[in] propSize
型: UINT
取得するプロパティ項目のサイズをバイト単位で指定する整数。 Image::GetPropertyItemSize メソッドを呼び出してサイズを決定します。
[out] buffer
Type: PropertyItem*
プロパティ項目を受け取る PropertyItem オブジェクトへのポインター。
戻り値
種類: 状態
メソッドが成功した場合は、 Status 列挙の要素である Ok を返します。
メソッドが失敗した場合は、 Status 列挙体の他の要素のいずれかを返します。
注釈
Image::GetPropertyItem メソッドは PropertyItem オブジェクトを返します。 Image::GetPropertyItem を呼び出す前に、そのオブジェクトを受け取るのに十分な大きさのバッファーを割り当てる必要があります。サイズは、プロパティ項目のデータ型と値によって異なります。 Image オブジェクトの Image::GetPropertyItemSize メソッドを呼び出して、必要なバッファーのサイズをバイト単位で取得できます。
例
次の例では、JPEG ファイルに基づいて Image オブジェクトを作成します。 このコードでは、PropertyTagEquipMake 定数を Image オブジェクトの Image::GetPropertyItem メソッドに渡すことで、 画像 をキャプチャしたカメラのメイクを取得します。
#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 であり、Gdiplusimaging.h で定義されている PropertyTagTypeASCII 定数の値であることに注意してください。
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 |
| ヘッダー | gdiplusheaders.h (Gdiplus.h を含む) |
| Library | Gdiplus.lib |
| [DLL] | Gdiplus.dll |