The GetImageEncoders function gets an array of ImageCodecInfo objects that contain information about the available image encoders.
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: 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
'삽질' 카테고리의 다른 글
image 포맷 변환. (0) | 2011.11.04 |
---|---|
ImageCodecInfo Class (0) | 2011.11.04 |
STL에서 동적할당 pointer 삭제 루틴. (0) | 2011.10.31 |
[ListCtrl] 아이템 외부 선택 - SetSelectionMark(), SetItemState(), SetFocus() (0) | 2011.10.15 |
Oracle 3개 Table 조인 (0) | 2011.10.13 |