[ATL] CImage: Hack fix for getting filter string (#5528)

- Fix the crash on opening/saving file.
- To get the filename extension info from CODECs, we have to keep gdiplus.dll loaded.
- The perfect fix will take time.
CORE-19093, CORE-19094
This commit is contained in:
Katayama Hirofumi MZ 2023-08-05 21:23:21 +09:00 committed by GitHub
parent b4bc6f0a6a
commit 36a35ee203
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -811,6 +811,7 @@ public:
DWORD dwExclude = excludeDefaultLoad,
TCHAR chSeparator = TEXT('|'))
{
CImage dummy; // HACK: Initialize common
UINT cDecoders = 0;
Gdiplus::ImageCodecInfo* pDecoders = _getAllDecoders(cDecoders);
HRESULT hr = BuildCodecFilterString(pDecoders,
@ -831,6 +832,7 @@ public:
DWORD dwExclude = excludeDefaultSave,
TCHAR chSeparator = TEXT('|'))
{
CImage dummy; // HACK: Initialize common
UINT cEncoders = 0;
Gdiplus::ImageCodecInfo* pEncoders = _getAllEncoders(cEncoders);
HRESULT hr = BuildCodecFilterString(pEncoders,
@ -1057,6 +1059,7 @@ protected:
// Deprecated. Don't use this
static const GUID *FileTypeFromExtension(LPCTSTR dotext)
{
CImage dummy; // HACK: Initialize common
UINT cEncoders = 0;
Gdiplus::ImageCodecInfo* pEncoders = _getAllEncoders(cEncoders);
@ -1111,6 +1114,7 @@ protected:
// Deprecated. Don't use this
static bool GetClsidFromFileType(CLSID *clsid, const GUID *guid)
{
CImage dummy; // HACK: Initialize common
UINT cEncoders = 0;
Gdiplus::ImageCodecInfo* pEncoders = _getAllEncoders(cEncoders);
*clsid = FindCodecForFileType(*guid, pEncoders, cEncoders);
@ -1120,8 +1124,6 @@ protected:
static Gdiplus::ImageCodecInfo* _getAllEncoders(UINT& cEncoders)
{
CImage image; // Initialize common
UINT total_size = 0;
GetCommon().GetImageEncodersSize(&cEncoders, &total_size);
if (total_size == 0)
@ -1141,8 +1143,6 @@ protected:
static Gdiplus::ImageCodecInfo* _getAllDecoders(UINT& cDecoders)
{
CImage image; // Initialize common
UINT total_size = 0;
GetCommon().GetImageDecodersSize(&cDecoders, &total_size);
if (total_size == 0)