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

類型: PropertyItem*

PropertyItem物件的陣列指標,該物件會接收屬性專案。

傳回值

類型: 狀態

如果方法成功,它會傳回 Ok,這是 Status 列舉的元素。

如果方法失敗,它會傳回 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

上述輸出會顯示每個屬性專案的十六進位識別碼。 您可以在 Gdiplusimaging.h 中查閱這些識別碼,並找出它們代表下列屬性標記。

十六進位值 屬性標記
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)
程式庫 Gdiplus.lib
Dll Gdiplus.dll

另請參閱

映像

Image::GetPropertyCount

Image::GetPropertyIdList

Image::GetPropertyItem

Image::GetPropertyItemSize

Image::GetPropertySize

Image::RemovePropertyItem

Image::SetPropertyItem

PropertyItem

讀取和寫入中繼資料