diff --git a/Texassemble/texassemble.cpp b/Texassemble/texassemble.cpp index 32dae5a..6cbceec 100644 --- a/Texassemble/texassemble.cpp +++ b/Texassemble/texassemble.cpp @@ -30,6 +30,14 @@ #include "directxtex.h" +//Uncomment to add support for OpenEXR (.exr) +//#define USE_OPENEXR + +#ifdef USE_OPENEXR +// See for details +#include "DirectXTexEXR.h" +#endif + using namespace DirectX; enum COMMANDS @@ -219,6 +227,7 @@ const SValue g_pFilters [] = #define CODEC_DDS 0xFFFF0001 #define CODEC_TGA 0xFFFF0002 #define CODEC_HDR 0xFFFF0005 +#define CODEC_EXR 0xFFFF0006 const SValue g_pExtFileTypes [] = { @@ -234,6 +243,9 @@ const SValue g_pExtFileTypes [] = { L".WDP", WIC_CODEC_WMP }, { L".HDP", WIC_CODEC_WMP }, { L".JXR", WIC_CODEC_WMP }, +#ifdef USE_OPENEXR + { L"EXR", CODEC_EXR }, +#endif { nullptr, CODEC_DDS } }; @@ -786,7 +798,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) case CMD_V_STRIP: if (_wcsicmp(ext, L".dds") == 0) { - hr = LoadFromDDSFile(pConv->szSrc, DDS_FLAGS_NONE, &info, *image.get()); + hr = LoadFromDDSFile(pConv->szSrc, DDS_FLAGS_NONE, &info, *image); if (FAILED(hr)) { wprintf(L" FAILED (%x)\n", hr); @@ -813,7 +825,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) default: if (_wcsicmp(ext, L".dds") == 0) { - hr = LoadFromDDSFile(pConv->szSrc, DDS_FLAGS_NONE, &info, *image.get()); + hr = LoadFromDDSFile(pConv->szSrc, DDS_FLAGS_NONE, &info, *image); if (FAILED(hr)) { wprintf(L" FAILED (%x)\n", hr); @@ -830,7 +842,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) } else if (_wcsicmp(ext, L".tga") == 0) { - hr = LoadFromTGAFile(pConv->szSrc, &info, *image.get()); + hr = LoadFromTGAFile(pConv->szSrc, &info, *image); if (FAILED(hr)) { wprintf(L" FAILED (%x)\n", hr); @@ -839,13 +851,24 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) } else if (_wcsicmp(ext, L".hdr") == 0) { - hr = LoadFromHDRFile(pConv->szSrc, &info, *image.get()); + hr = LoadFromHDRFile(pConv->szSrc, &info, *image); if (FAILED(hr)) { wprintf(L" FAILED (%x)\n", hr); return 1; } } +#ifdef USE_OPENEXR + else if (_wcsicmp(ext, L".exr") == 0) + { + hr = LoadFromEXRFile(pConv->szSrc, &info, *image); + if (FAILED(hr)) + { + wprintf(L" FAILED (%x)\n", hr); + continue; + } + } +#endif else { // WIC shares the same filter values for mode and dither @@ -856,7 +879,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) static_assert(WIC_FLAGS_FILTER_CUBIC == TEX_FILTER_CUBIC, "WIC_FLAGS_* & TEX_FILTER_* should match"); static_assert(WIC_FLAGS_FILTER_FANT == TEX_FILTER_FANT, "WIC_FLAGS_* & TEX_FILTER_* should match"); - hr = LoadFromWICFile(pConv->szSrc, dwFilter | WIC_FLAGS_ALL_FRAMES, &info, *image.get()); + hr = LoadFromWICFile(pConv->szSrc, dwFilter | WIC_FLAGS_ALL_FRAMES, &info, *image); if (FAILED(hr)) { wprintf(L" FAILED (%x)\n", hr); @@ -1253,6 +1276,12 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) hr = SaveToHDRFile(*dest, szOutputFile); break; +#ifdef USE_OPENEXR + case CODEC_EXR: + hr = SaveToEXRFile(*dest, szOutputFile); + break; +#endif + default: hr = SaveToWICFile(*dest, WIC_FLAGS_NONE, GetWICCodec(static_cast(CrossFileType)), szOutputFile); break; diff --git a/Texdiag/texdiag.cpp b/Texdiag/texdiag.cpp index 2c679d0..07fef39 100644 --- a/Texdiag/texdiag.cpp +++ b/Texdiag/texdiag.cpp @@ -30,6 +30,14 @@ #include "directxtex.h" +//Uncomment to add support for OpenEXR (.exr) +//#define USE_OPENEXR + +#ifdef USE_OPENEXR +// See for details +#include "DirectXTexEXR.h" +#endif + using namespace DirectX; enum COMMANDS @@ -281,6 +289,7 @@ const SValue g_pFilters[] = #define CODEC_DDS 0xFFFF0001 #define CODEC_TGA 0xFFFF0002 #define CODEC_HDR 0xFFFF0005 +#define CODEC_EXR 0xFFFF0006 const SValue g_pExtFileTypes[] = { @@ -296,6 +305,9 @@ const SValue g_pExtFileTypes[] = { L".WDP", WIC_CODEC_WMP }, { L".HDP", WIC_CODEC_WMP }, { L".JXR", WIC_CODEC_WMP }, +#ifdef USE_OPENEXR + { L"EXR", CODEC_EXR }, +#endif { nullptr, CODEC_DDS } }; @@ -527,7 +539,7 @@ namespace if (dwOptions & (1 << OPT_DDS_BAD_DXTN_TAILS)) ddsFlags |= DDS_FLAGS_BAD_DXTN_TAILS; - HRESULT hr = LoadFromDDSFile(fileName, ddsFlags, &info, *image.get()); + HRESULT hr = LoadFromDDSFile(fileName, ddsFlags, &info, *image); if (FAILED(hr)) return hr; @@ -552,12 +564,18 @@ namespace } else if (_wcsicmp(ext, L".tga") == 0) { - return LoadFromTGAFile(fileName, &info, *image.get()); + return LoadFromTGAFile(fileName, &info, *image); } else if (_wcsicmp(ext, L".hdr") == 0) { - return LoadFromHDRFile(fileName, &info, *image.get()); + return LoadFromHDRFile(fileName, &info, *image); } +#ifdef USE_OPENEXR + else if (_wcsicmp(ext, L".exr") == 0) + { + return LoadFromEXRFile(fileName, &info, *image); + } +#endif else { // WIC shares the same filter values for mode and dither @@ -568,7 +586,7 @@ namespace static_assert(WIC_FLAGS_FILTER_CUBIC == TEX_FILTER_CUBIC, "WIC_FLAGS_* & TEX_FILTER_* should match"); static_assert(WIC_FLAGS_FILTER_FANT == TEX_FILTER_FANT, "WIC_FLAGS_* & TEX_FILTER_* should match"); - return LoadFromWICFile(fileName, dwFilter | WIC_FLAGS_ALL_FRAMES, &info, *image.get()); + return LoadFromWICFile(fileName, dwFilter | WIC_FLAGS_ALL_FRAMES, &info, *image); } } @@ -585,6 +603,11 @@ namespace case CODEC_HDR: return SaveToHDRFile(*image, fileName); +#ifdef USE_OPENEXR + case CODEC_EXR: + return SaveToEXRFile(*image, fileName); +#endif + default: return SaveToWICFile(*image, WIC_FLAGS_NONE, GetWICCodec(static_cast(codec)), fileName); }