Image::GetPropertyItemSize 方法 (gdiplusheaders.h)

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)
程式庫 Gdiplus.lib
Dll Gdiplus.dll

另請參閱

映像

Image::GetAllPropertyItems

Image::GetPropertyCount

Image::GetPropertyIdList

Image::GetPropertyItem

Image::GetPropertySize

Image::RemovePropertyItem

Image::SetPropertyItem

PropertyItem

讀取和寫入中繼資料