Export (0) Print
Expand All

GetImageEncoders function

Applies to: desktop apps only

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

Syntax

Status GetImageEncoders(
  __in   UINT numEncoders,
  __in   UINT size,
  __out  ImageCodecInfo *encoders
);

Parameters

numEncoders [in]

Type: UINT

Integer that specifies the number of available image encoders. Call GetImageEncodersSize to determine this number.

size [in]

Type: UINT

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

encoders [out]

Type: ImageCodecInfo*

Pointer to a buffer that receives the array of ImageCodecInfo objects. You must allocate memory for this buffer. Call GetImageEncodersSize 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 encoders:


#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 encoders
   UINT  size;       // size, in bytes, of the image encoder array

   ImageCodecInfo* pImageCodecInfo;

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

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

   // GetImageEncoders 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. 
   GetImageEncoders(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/tiff
image/png

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
GetImageDecoders
GetImageEncodersSize
Image
Metafile
Using Image Encoders and Decoders

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions

ADD
Show:
© 2014 Microsoft