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

@@ -712,9 +712,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;
}
@@ -799,7 +798,19 @@ namespace
static_assert(static_cast<int>(WIC_FLAGS_FILTER_CUBIC) == static_cast<int>(TEX_FILTER_CUBIC), "WIC_FLAGS_* & TEX_FILTER_* should match");
static_assert(static_cast<int>(WIC_FLAGS_FILTER_FANT) == static_cast<int>(TEX_FILTER_FANT), "WIC_FLAGS_* & TEX_FILTER_* should match");
return LoadFromWICFile(fileName, dwFilter | WIC_FLAGS_ALL_FRAMES, &info, *image);
HRESULT hr = LoadFromWICFile(fileName, dwFilter | WIC_FLAGS_ALL_FRAMES, &info, *image);
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"\nINFO: This format requires installing the HEIF Image Extensions - https://aka.ms/heif\n");
}
else if (_wcsicmp(ext, L".webp") == 0)
{
wprintf(L"\nINFO: This format requires installing the WEBP Image Extensions - https://www.microsoft.com/p/webp-image-extensions/9pg2dk419drg\n");
}
}
return hr;
}
}