From 2bc635fa6bd301b3a9fbf7116a0ff261afb71d9c Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Wed, 6 Nov 2024 20:41:59 -0800 Subject: [PATCH 1/2] Fix -Wsign-conversion warning --- Auxiliary/DirectXTexEXR.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Auxiliary/DirectXTexEXR.cpp b/Auxiliary/DirectXTexEXR.cpp index 1de9271b..529ceaa2 100644 --- a/Auxiliary/DirectXTexEXR.cpp +++ b/Auxiliary/DirectXTexEXR.cpp @@ -220,7 +220,7 @@ HRESULT DirectX::GetMetadataFromEXRFile(const wchar_t* szFile, TexMetadata& meta const int nameLength = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, nullptr, 0, nullptr, nullptr); if (nameLength > 0) { - fileName.resize(nameLength); + fileName.resize(static_cast(nameLength)); const int result = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, fileName.data(), nameLength, nullptr, nullptr); if (result <= 0) { @@ -338,7 +338,7 @@ HRESULT DirectX::LoadFromEXRFile(const wchar_t* szFile, TexMetadata* metadata, S const int nameLength = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, nullptr, 0, nullptr, nullptr); if (nameLength > 0) { - fileName.resize(nameLength); + fileName.resize(static_cast(nameLength)); const int result = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, fileName.data(), nameLength, nullptr, nullptr); if (result <= 0) { @@ -487,7 +487,7 @@ HRESULT DirectX::SaveToEXRFile(const Image& image, const wchar_t* szFile) const int nameLength = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, nullptr, 0, nullptr, nullptr); if (nameLength > 0) { - fileName.resize(nameLength); + fileName.resize(static_cast(nameLength)); const int result = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, fileName.data(), nameLength, nullptr, nullptr); if (result <= 0) { From cdfe8cc901906f2ebd2a8a5d5932598e0eb84947 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Wed, 6 Nov 2024 21:10:27 -0800 Subject: [PATCH 2/2] Fix C4266 warning --- Auxiliary/DirectXTexEXR.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Auxiliary/DirectXTexEXR.cpp b/Auxiliary/DirectXTexEXR.cpp index 529ceaa2..09a6e2ee 100644 --- a/Auxiliary/DirectXTexEXR.cpp +++ b/Auxiliary/DirectXTexEXR.cpp @@ -45,8 +45,13 @@ #pragma warning(disable : 4244 4996) #include #include + +// https://openexr.com/en/latest/PortingGuide.html +#include #pragma warning(pop) +#define COMBINED_OPENEXR_VERSION ((10000*OPENEXR_VERSION_MAJOR) + (100*OPENEXR_VERSION_MINOR) + OPENEXR_VERSION_PATCH) + #ifdef __clang__ #pragma clang diagnostic pop #endif @@ -148,6 +153,13 @@ namespace SetLastError(0); } +#if COMBINED_OPENEXR_VERSION >= 30300 + int64_t read(void *buf, uint64_t sz, uint64_t offset) override + { + return Imf::IStream::read(buf, sz, offset); + } +#endif + private: HANDLE m_hFile; LONGLONG m_EOF;