This commit is contained in:
恍兮惚兮 2025-01-03 01:19:42 +08:00
parent d4f16add89
commit 1ff6c2567f

View File

@ -29,30 +29,21 @@ 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
Gdiplus::ImageCodecInfo *pImageCodecInfo = NULL;
Gdiplus::GetImageEncodersSize(&num, &size);
if (size == 0)
return -1; // Failure
pImageCodecInfo = (Gdiplus::ImageCodecInfo *)(malloc(size));
if (pImageCodecInfo == NULL)
return -1; // Failure
GetImageEncoders(num, size, pImageCodecInfo);
auto pImageCodecInfo = std::make_unique<Gdiplus::ImageCodecInfo[]>(num);
GetImageEncoders(num, size, pImageCodecInfo.get());
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
}
void capture_window(HWND window_handle, void (*cb)(byte *, size_t))