INT GetEncoderClsid(const WCHAR *format, CLSID *pClsid) 函数源码

GetEncoderClsid函数来获取一个编码器的MIME (多用途网际邮件扩充协议)类型,然后返回该编码器的类标识符(CLSID)。GDI+中编码器的MIME类型如下:
image/bmp
image/jpeg
image/gif
image/tiff
image/png
INT GetEncoderClsid(const WCHAR *format, CLSID *pClsid) { UINT num = 0; // number of image encoders UINT size = 0; // size of the image encoder array in bytes ImageCodecInfo* pImageCodecInfo = NULL; GetImageEncodersSize(&num, &size); if(size == 0) return -1; // Failure pImageCodecInfo = (ImageCodecInfo*)(malloc(size)); if(pImageCodecInfo == NULL) return -1; // Failure GetImageEncoders(num, size, pImageCodecInfo); for(UINT j = 0; j < num; ++j) { if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 ) { *pClsid = pImageCodecInfo[j].Clsid; free(pImageCodecInfo); return j; // Success } } free(pImageCodecInfo); return -1; // Failure }

你可能感兴趣的:(image,null,GDI+)