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

Image::SetPropertyItem メソッドは、この Image オブジェクトのプロパティ項目 (メタデータの一部) を設定します。 項目が既に存在する場合は、その内容が更新されます。それ以外の場合は、新しい項目が追加されます。

構文

Status SetPropertyItem(
  [in] const PropertyItem *item
);

パラメーター

[in] item

型: const PropertyItem*

設定するプロパティ項目を指定する PropertyItem オブジェクトへのポインター。

戻り値

種類: 状態

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

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

注釈

特定のイメージ形式 (ICON や EMF など) では、プロパティがサポートされていません。 プロパティをサポートしていない イメージで Image::SetPropertyItem メソッドを呼び出すと、PropertyNotSupported が返されます。

次のコンソール アプリケーションは、JPEG ファイルに基づいて Image オブジェクトを作成します。 このコードは、その Image オブジェクトの Image::SetPropertyItem メソッドを呼び出して、イメージのタイトルを設定します。 その後、コードは新しいタイトルを取得して表示します。

#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");

   // Set the image title.
   PropertyItem* propItem = new PropertyItem;
   CHAR newTitleValue[] = "Fake Photograph 2";

   propItem->id = PropertyTagImageTitle;
   propItem->length = 18;  //  includes null terminator
   propItem->type = PropertyTagTypeASCII;
   propItem->value = newTitleValue;

   image->SetPropertyItem(propItem);

   // Get and display the new image title.
   UINT size = image->GetPropertyItemSize(PropertyTagImageTitle);
   PropertyItem* title = (PropertyItem*)malloc(size);
   image->GetPropertyItem(PropertyTagImageTitle, size, title);
   printf("The image title is %s.\n", title->value);

   free(title);
   delete propItem;
   delete image;
   GdiplusShutdown(gdiplusToken);
   return 0;
}

要件

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

こちらもご覧ください

Image

Image::GetPropertyCount

Image::GetPropertyIdList

Image::GetPropertyItem

Image::GetPropertyItemSize

Image::GetPropertySize

Image::RemovePropertyItem

PropertyItem

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