Image::GetFrameDimensionsCount 方法 (gdiplusheaders.h)

Image::GetFrameDimensionsCount方法會取得此Image物件中的框架維度數目。

Syntax

UINT GetFrameDimensionsCount();

傳回值

類型: UINT

這個方法會傳回這個 Image 物件中的框架維度數目。

備註

這個方法會傳回多個畫面格影像的相關資訊,這些影像有兩種樣式:多個頁面和多個解析度。

多頁影像是包含多個影像的影像。 每個頁面都包含單一影像 (或框架) 。 這些頁面 (或影像,或畫面格) 通常會連續顯示,以產生動畫序列,例如在動畫 GIF 檔案中。

多重解析度影像是一個影像,其中包含不同解析度影像的多個複本。

Windows GDI+ 可以支援任意數目的頁面 (或影像,或框架) ,以及任意數目的解析度。

範例

下列主控台應用程式會根據 TIFF 檔案建立 Image 物件。 程式碼會呼叫 Image::GetFrameDimensionsCount 方法,以找出 Image 物件擁有多少框架維度。 每個框架維度都是由 GUID 識別,而 Image::GetFrameDimensionsList 的呼叫會擷取這些 GUID。 第一個 GUID 位於 pDimensionIDs 陣列中的索引 0。 呼叫 Image::GetFrameCount 方法會決定第一個 GUID 所識別維度中的框架數目。

#include <windows.h>
#include <gdiplus.h>
#include <stdio.h>
using namespace Gdiplus;

INT main()
{
   GdiplusStartupInput gdiplusStartupInput;
   ULONG_PTR gdiplusToken;
   GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

   Image* image = new Image(L"Multiframe.tif");

   // How many frame dimensions does the Image object have?
   UINT count = 0;
   count = image->GetFrameDimensionsCount();
   printf("The number of dimensions is %d.\n", count);
   GUID* pDimensionIDs = (GUID*)malloc(sizeof(GUID)*count);

   // Get the list of frame dimensions from the Image object.
   image->GetFrameDimensionsList(pDimensionIDs, count);

   // Display the GUID of the first (and only) frame dimension.
   WCHAR strGuid[39];
   StringFromGUID2(pDimensionIDs[0], strGuid, 39);
   wprintf(L"The first (and only) dimension ID is %s.\n", strGuid);

   // Get the number of frames in the first dimension.
   UINT frameCount = image->GetFrameCount(&pDimensionIDs[0]);
   printf("The number of frames in that dimension is %d.\n", frameCount);
    
   free(pDimensionIDs);
   delete(image);
   GdiplusShutdown(gdiplusToken);
   return 0;
}

上述程式碼以及特定檔案 Multiframe.tif 會產生下列輸出:

The number of dimensions is 1.
The first (and only) dimension ID is {7462DC86-6180-4C7E-8E3F-EE7333A7A483}.
The number of frames in that dimension is 4.

您可以在 Gdiplusimaging.h 中查閱顯示的 GUID,並查看它是頁面維度的識別碼。 因此,程式輸出會告訴我們 Multiframe.tif 檔案有四個頁面;也就是頁面維度中的四個畫面。

需求

   
最低支援的用戶端 Windows XP、Windows 2000 Professional [僅限傳統型應用程式]
最低支援的伺服器 Windows 2000 Server [僅限傳統型應用程式]
目標平台 Windows
標頭 gdiplusheaders.h (包含 Gdiplus.h)
程式庫 Gdiplus.lib
Dll Gdiplus.dll

另請參閱

從 Multiple-Frame 影像複製個別畫面格

建立和儲存多框架影像

EncoderParameter

映像

Image::GetFrameCount

Image::GetFrameDimensionsList

Image::SaveAdd 方法