Export (0) Print
Expand All

Image.GetFrameCount method

Applies to: desktop apps only

The Image::GetFrameCount method gets the number of frames in a specified dimension of this Image object.

Syntax

UINT GetFrameCount(
  [in]  const GUID *dimensionID
);

Parameters

dimensionID [in]

Type: const GUID*

Pointer to a GUID that specifies the dimension. GUIDs that identify various dimensions are defined in Gdiplusimaging.h.

Return value

Type:

Type: UINT

This method returns the number of frames in the specified dimension of this Image object.

Examples

The following console application creates an Image object based on a TIFF file. The code calls the Image::GetFrameDimensionsCount method to find out how many frame dimensions the Image object has. Each of those frame dimensions is identified by a GUID, and the call to Image::GetFrameDimensionsList retrieves those GUIDs. The first GUID is at index 0 in the pDimensionIDs array. The call to the Image::GetFrameCount method determines the number of frames in the dimension identified by the first 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;
}

The preceding code, along with a particular file, Multiframe.tif, produced the following output:


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.

Requirements

Minimum supported client

Windows XP, Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Product

GDI+ 1.0

Header

Gdiplusheaders.h (include Gdiplus.h)

Library

Gdiplus.lib

DLL

Gdiplus.dll

See also

Image
EncoderParameter
Image::GetFrameDimensionsCount
Image::GetFrameDimensionsList
Image::SaveAdd Methods
Copying Individual Frames from a Multiple-Frame Image
Creating and Saving a Multiple-Frame Image

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions

ADD
Show:
© 2014 Microsoft