Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

GetImageDecoders function

Applies to: desktop apps only

The GetImageDecoders function gets an array of ImageCodecInfo objects that contain information about the available image decoders.

Syntax

Status GetImageDecoders(
  __in   UINT numDecoders,
  __in   UINT size,
  __out  ImageCodecInfo *decoders
);

Parameters

numDecoders [in]

Type: UINT

Integer that specifies the number of available image decoders. Call GetImageDecodersSize to determine this number.

size [in]

Type: UINT

Integer that specifies the size, in bytes, of the array of ImageCodecInfo objects. Call GetImageDecodersSize to determine this number.

decoders [out]

Type: ImageCodecInfo*

Pointer to a buffer that receives the array of ImageCodecInfo objects. You must allocate memory for this buffer. Call GetImageDecodersSize to determine the size of the required buffer.

Return value

Type:

Type: Status

If the function succeeds, it returns Ok, which is an element of the Status enumeration.

If the function fails, it returns one of the other elements of the Status enumeration.

Examples

The following console application lists the available image decoders:


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

INT main()
{
   // Initialize GDI+.
   GdiplusStartupInput gdiplusStartupInput;
   ULONG_PTR           gdiplusToken;
   GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
  
   UINT  num;        // number of image decoders
   UINT  size;       // size, in bytes, of the image decoder array

   ImageCodecInfo* pImageCodecInfo;

   // How many decoders are there?
   // How big (in bytes) is the array of all ImageCodecInfo objects?
   GetImageDecodersSize(&num, &size);

   // Create a buffer large enough to hold the array of ImageCodecInfo
   // objects that will be returned by GetImageDecoders.
   pImageCodecInfo = (ImageCodecInfo*)(malloc(size));

   // GetImageDecoders creates an array of ImageCodecInfo objects
   // and copies that array into a previously allocated buffer. 
   // The third argument, imageCodecInfos, is a pointer to that buffer. 
   GetImageDecoders(num, size, pImageCodecInfo);

   // Display the graphics file format (MimeType)
   // for each ImageCodecInfo object.
   for(UINT j = 0; j < num; ++j)
   { 
      wprintf(L"%s\n", pImageCodecInfo[j].MimeType);   
   }

   free(pImageCodecInfo);
   GdiplusShutdown(gdiplusToken);
   return 0;
}

The preceding code produces the following output:


image/bmp
image/jpeg
image/gif
image/x-emf
image/x-wmf
image/tiff
image/png
image/x-icon

Requirements

Minimum supported client

Windows XP, Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Product

GDI+ 1.0

Header

Gdiplusimagecodec.h (include Gdiplus.h)

Library

Gdiplus.lib

See also

Bitmap
GetImageDecodersSize
GetImageEncoders
GetImageEncodersSize
Image
Metafile
Using Image Encoders and Decoders

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.