|
45 | 45 | #pragma warning(disable : 4244 4996)
|
46 | 46 | #include <ImfRgbaFile.h>
|
47 | 47 | #include <ImfIO.h>
|
| 48 | + |
| 49 | +// https://openexr.com/en/latest/PortingGuide.html |
| 50 | +#include <OpenEXRConfig.h> |
48 | 51 | #pragma warning(pop)
|
49 | 52 |
|
| 53 | +#define COMBINED_OPENEXR_VERSION ((10000*OPENEXR_VERSION_MAJOR) + (100*OPENEXR_VERSION_MINOR) + OPENEXR_VERSION_PATCH) |
| 54 | + |
50 | 55 | #ifdef __clang__
|
51 | 56 | #pragma clang diagnostic pop
|
52 | 57 | #endif
|
@@ -148,6 +153,13 @@ namespace
|
148 | 153 | SetLastError(0);
|
149 | 154 | }
|
150 | 155 |
|
| 156 | +#if COMBINED_OPENEXR_VERSION >= 30300 |
| 157 | + int64_t read(void *buf, uint64_t sz, uint64_t offset) override |
| 158 | + { |
| 159 | + return Imf::IStream::read(buf, sz, offset); |
| 160 | + } |
| 161 | +#endif |
| 162 | + |
151 | 163 | private:
|
152 | 164 | HANDLE m_hFile;
|
153 | 165 | LONGLONG m_EOF;
|
@@ -220,7 +232,7 @@ HRESULT DirectX::GetMetadataFromEXRFile(const wchar_t* szFile, TexMetadata& meta
|
220 | 232 | const int nameLength = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, nullptr, 0, nullptr, nullptr);
|
221 | 233 | if (nameLength > 0)
|
222 | 234 | {
|
223 |
| - fileName.resize(nameLength); |
| 235 | + fileName.resize(static_cast<size_t>(nameLength)); |
224 | 236 | const int result = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, fileName.data(), nameLength, nullptr, nullptr);
|
225 | 237 | if (result <= 0)
|
226 | 238 | {
|
@@ -338,7 +350,7 @@ HRESULT DirectX::LoadFromEXRFile(const wchar_t* szFile, TexMetadata* metadata, S
|
338 | 350 | const int nameLength = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, nullptr, 0, nullptr, nullptr);
|
339 | 351 | if (nameLength > 0)
|
340 | 352 | {
|
341 |
| - fileName.resize(nameLength); |
| 353 | + fileName.resize(static_cast<size_t>(nameLength)); |
342 | 354 | const int result = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, fileName.data(), nameLength, nullptr, nullptr);
|
343 | 355 | if (result <= 0)
|
344 | 356 | {
|
@@ -487,7 +499,7 @@ HRESULT DirectX::SaveToEXRFile(const Image& image, const wchar_t* szFile)
|
487 | 499 | const int nameLength = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, nullptr, 0, nullptr, nullptr);
|
488 | 500 | if (nameLength > 0)
|
489 | 501 | {
|
490 |
| - fileName.resize(nameLength); |
| 502 | + fileName.resize(static_cast<size_t>(nameLength)); |
491 | 503 | const int result = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, fileName.data(), nameLength, nullptr, nullptr);
|
492 | 504 | if (result <= 0)
|
493 | 505 | {
|
|
0 commit comments