Add support for HEIF and WEBP to command-line tools (#268)

This commit is contained in:
Chuck Walbourn
2022-03-02 14:25:27 -08:00
committed by GitHub
parent 2eb309d197
commit 1c20d528d4
6 changed files with 59 additions and 10 deletions

View File

@@ -443,6 +443,8 @@ namespace
#ifdef USE_OPENEXR
{ L"exr", CODEC_EXR },
#endif
{ L"heic", WIC_CODEC_HEIF },
{ L"heif", WIC_CODEC_HEIF },
{ nullptr, CODEC_DDS }
};
@@ -1000,9 +1002,8 @@ namespace
swprintf_s(desc, L": %ls", errorText);
size_t len = wcslen(desc);
if (len >= 2)
if (len >= 1)
{
desc[len - 2] = 0;
desc[len - 1] = 0;
}
@@ -2118,6 +2119,17 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
{
wprintf(L" FAILED (%08X%ls)\n", static_cast<unsigned int>(hr), GetErrorDesc(hr));
retVal = 1;
if (hr == static_cast<HRESULT>(0xc00d5212) /* MF_E_TOPO_CODEC_NOT_FOUND */)
{
if (_wcsicmp(ext, L".heic") == 0 || _wcsicmp(ext, L".heif") == 0)
{
wprintf(L"INFO: This format requires installing the HEIF Image Extensions - https://aka.ms/heif\n");
}
else if (_wcsicmp(ext, L".webp") == 0)
{
wprintf(L"INFO: This format requires installing the WEBP Image Extensions - https://www.microsoft.com/p/webp-image-extensions/9pg2dk419drg\n");
}
}
continue;
}
}
@@ -3691,6 +3703,10 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
{
wprintf(L" FAILED (%08X%ls)\n", static_cast<unsigned int>(hr), GetErrorDesc(hr));
retVal = 1;
if ((hr == static_cast<HRESULT>(0xc00d5212) /* MF_E_TOPO_CODEC_NOT_FOUND */) && (FileType == WIC_CODEC_HEIF))
{
wprintf(L"INFO: This format requires installing the HEIF Image Extensions - https://aka.ms/heif\n");
}
continue;
}
wprintf(L"\n");