Image::GetPropertyItemSize メソッドは、この Image オブジェクトの指定したプロパティ項目のサイズをバイト単位で取得します。
構文
UINT GetPropertyItemSize(
[in] PROPID propId
);
パラメーター
[in] propId
型: PROPID
プロパティ項目を識別する整数。
戻り値
型: UINT
このメソッドは、この Image オブジェクトの指定したプロパティ項目のサイズをバイト単位で返します。
解説
Image::GetPropertyItem メソッドは PropertyItem オブジェクトを返します。 Image::GetPropertyItem を呼び出す前に、そのオブジェクトを受け取るのに十分な大きさのバッファーを割り当てる必要があります。サイズは、プロパティ項目のデータ型と値によって異なります。 Image オブジェクトの Image::GetPropertyItemSize メソッドを呼び出して、必要なバッファーのサイズをバイト単位で取得できます。
例
次の例では、JPEG ファイルに基づいて Image オブジェクトを作成します。 このコードでは、その Image オブジェクトの Image::GetPropertyItemSize メソッドを呼び出して、画像のキャプチャに使用されるカメラのメイクを保持するプロパティ項目のサイズを取得します。 次に、 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 |