【可以使用下面的程序获得本机的GDI+编解码器列表】
#include <iostream>
#include <Windows.h>
#include <GdiPlus.h>
#pragma comment(lib, "Gdiplus.lib")
using namespace std;
using namespace Gdiplus;
void show(void)
{
UINT uNum, uSize;
GetImageEncodersSize(&uNum, &uSize);
cout << "个数: " << uNum << endl;
cout << "大小: " << uSize << endl;
if (uSize == 0)
return; // malloc(0)也能分配成功, 但无意义
ImageCodecInfo *pInfo = (ImageCodecInfo *)malloc(uSize);
if (pInfo == NULL)
{
cout << "内存分配失败" << endl;
return;
}
GetImageEncoders(uNum, uSize, pInfo);
UINT i;
for (i = 0; i < uNum; i++)
{
wcout << '[' << pInfo[i].CodecName << ']' << endl;
wcout << "MimeType: " << pInfo[i].MimeType << endl;
if (pInfo[i].DllName != NULL)
wcout << "DllName: " << pInfo[i].DllName << endl;
wcout << "FormatDescription: " << pInfo[i].FormatDescription << endl;
wcout << "FilenameExtension: " << pInfo[i].FilenameExtension << endl;
wcout << "Version: " << pInfo[i].Version << endl;
wcout << endl;
}
free(pInfo);
}
int main(void)
{
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
show();
GdiplusShutdown(gdiplusToken);
system("pause");
return 0;
}