mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2025-01-13 15:43:53 +08:00
.
This commit is contained in:
parent
d4f16add89
commit
1ff6c2567f
@ -29,30 +29,21 @@ int GetEncoderClsid(const WCHAR *format, CLSID *pClsid)
|
|||||||
{
|
{
|
||||||
UINT num = 0; // number of image encoders
|
UINT num = 0; // number of image encoders
|
||||||
UINT size = 0; // size of the image encoder array in bytes
|
UINT size = 0; // size of the image encoder array in bytes
|
||||||
|
|
||||||
Gdiplus::ImageCodecInfo *pImageCodecInfo = NULL;
|
|
||||||
|
|
||||||
Gdiplus::GetImageEncodersSize(&num, &size);
|
Gdiplus::GetImageEncodersSize(&num, &size);
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return -1; // Failure
|
return -1; // Failure
|
||||||
|
|
||||||
pImageCodecInfo = (Gdiplus::ImageCodecInfo *)(malloc(size));
|
auto pImageCodecInfo = std::make_unique<Gdiplus::ImageCodecInfo[]>(num);
|
||||||
if (pImageCodecInfo == NULL)
|
GetImageEncoders(num, size, pImageCodecInfo.get());
|
||||||
return -1; // Failure
|
|
||||||
|
|
||||||
GetImageEncoders(num, size, pImageCodecInfo);
|
|
||||||
|
|
||||||
for (UINT j = 0; j < num; ++j)
|
for (UINT j = 0; j < num; ++j)
|
||||||
{
|
{
|
||||||
if (wcscmp(pImageCodecInfo[j].MimeType, format) == 0)
|
if (wcscmp(pImageCodecInfo[j].MimeType, format) == 0)
|
||||||
{
|
{
|
||||||
*pClsid = pImageCodecInfo[j].Clsid;
|
*pClsid = pImageCodecInfo[j].Clsid;
|
||||||
free(pImageCodecInfo);
|
|
||||||
return j; // Success
|
return j; // Success
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(pImageCodecInfo);
|
|
||||||
return -1; // Failure
|
return -1; // Failure
|
||||||
}
|
}
|
||||||
void capture_window(HWND window_handle, void (*cb)(byte *, size_t))
|
void capture_window(HWND window_handle, void (*cb)(byte *, size_t))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user