diff --git a/DirectXTex/DirectXTex.h b/DirectXTex/DirectXTex.h index 896d288..051f2eb 100644 --- a/DirectXTex/DirectXTex.h +++ b/DirectXTex/DirectXTex.h @@ -819,6 +819,7 @@ namespace DirectX WIC_CODEC_GIF, // Graphics Interchange Format (.gif) WIC_CODEC_WMP, // Windows Media Photo / HD Photo / JPEG XR (.hdp, .jxr, .wdp) WIC_CODEC_ICO, // Windows Icon (.ico) + WIC_CODEC_HEIF, // High Efficiency Image File (.heif, .heic) }; REFGUID __cdecl GetWICCodec(_In_ WICCodecs codec) noexcept; diff --git a/DirectXTex/DirectXTexUtil.cpp b/DirectXTex/DirectXTexUtil.cpp index 2d033f7..ed312c1 100644 --- a/DirectXTex/DirectXTexUtil.cpp +++ b/DirectXTex/DirectXTexUtil.cpp @@ -270,6 +270,10 @@ REFGUID DirectX::GetWICCodec(WICCodecs codec) noexcept case WIC_CODEC_ICO: return GUID_ContainerFormatIco; + case WIC_CODEC_HEIF: + // This requires installing https://aka.ms/heif + return GUID_ContainerFormatHeif; + default: return GUID_NULL; } diff --git a/DirectXTex/DirectXTexWIC.cpp b/DirectXTex/DirectXTexWIC.cpp index 1ea1fb7..16c22e7 100644 --- a/DirectXTex/DirectXTexWIC.cpp +++ b/DirectXTex/DirectXTexWIC.cpp @@ -1569,7 +1569,7 @@ HRESULT DirectX::SaveToWICFile( if (FAILED(hr)) { stream.Reset(); - DeleteFileW(szFile); + std::ignore = DeleteFileW(szFile); return hr; } @@ -1611,7 +1611,7 @@ HRESULT DirectX::SaveToWICFile( if (FAILED(hr)) { stream.Reset(); - DeleteFileW(szFile); + std::ignore = DeleteFileW(szFile); return hr; } diff --git a/Texassemble/texassemble.cpp b/Texassemble/texassemble.cpp index 9113e85..c74a104 100644 --- a/Texassemble/texassemble.cpp +++ b/Texassemble/texassemble.cpp @@ -709,9 +709,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; } @@ -792,7 +791,14 @@ namespace #endif default: - return SaveToWICFile(img, WIC_FLAGS_NONE, GetWICCodec(static_cast(fileType)), szOutputFile); + { + HRESULT hr = SaveToWICFile(img, WIC_FLAGS_NONE, GetWICCodec(static_cast(fileType)), szOutputFile); + if ((hr == static_cast(0xc00d5212) /* MF_E_TOPO_CODEC_NOT_FOUND */) && (fileType == WIC_CODEC_HEIF)) + { + wprintf(L"\nINFO: This format requires installing the HEIF Image Extensions - https://aka.ms/heif\n"); + } + return hr; + } } } @@ -1477,6 +1483,17 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) if (FAILED(hr)) { wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); + if (hr == static_cast(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"); + } + } return 1; } } diff --git a/Texconv/texconv.cpp b/Texconv/texconv.cpp index e8fdae2..47e4c4a 100644 --- a/Texconv/texconv.cpp +++ b/Texconv/texconv.cpp @@ -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(hr), GetErrorDesc(hr)); retVal = 1; + if (hr == static_cast(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(hr), GetErrorDesc(hr)); retVal = 1; + if ((hr == static_cast(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"); diff --git a/Texdiag/texdiag.cpp b/Texdiag/texdiag.cpp index c66d384..13d073d 100644 --- a/Texdiag/texdiag.cpp +++ b/Texdiag/texdiag.cpp @@ -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(WIC_FLAGS_FILTER_CUBIC) == static_cast(TEX_FILTER_CUBIC), "WIC_FLAGS_* & TEX_FILTER_* should match"); static_assert(static_cast(WIC_FLAGS_FILTER_FANT) == static_cast(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(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; } }