diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-04-05 15:46:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-05 15:46:23 +0200 |
commit | c9aa0c20a0cf57ad573564942c53143a2980e526 (patch) | |
tree | 8867d41204997e17ce16906672c2b146f3c43bf5 | |
parent | 434b73bc576ae7e6752c065137d702f3b3cfe085 (diff) | |
parent | f0562a5ef61d9e0e13ad1408b1cb5c6ae901552d (diff) |
Merge pull request #27327 from goodyttoor/grayscale_exr
Fix import grayscale EXR
-rw-r--r-- | modules/tinyexr/image_loader_tinyexr.cpp | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/modules/tinyexr/image_loader_tinyexr.cpp b/modules/tinyexr/image_loader_tinyexr.cpp index e69d9a0ae3..bd84a28c84 100644 --- a/modules/tinyexr/image_loader_tinyexr.cpp +++ b/modules/tinyexr/image_loader_tinyexr.cpp @@ -107,22 +107,31 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f } } - if (idxR == -1) { - ERR_PRINT("TinyEXR: R channel not found."); - // @todo { free exr_image } - return ERR_FILE_CORRUPT; - } + if (exr_header.num_channels == 1) { + // Grayscale channel only. + idxR = 0; + idxG = 0; + idxB = 0; + idxA = 0; + } else { + // Assume RGB(A) + if (idxR == -1) { + ERR_PRINT("TinyEXR: R channel not found."); + // @todo { free exr_image } + return ERR_FILE_CORRUPT; + } - if (idxG == -1) { - ERR_PRINT("TinyEXR: G channel not found.") - // @todo { free exr_image } - return ERR_FILE_CORRUPT; - } + if (idxG == -1) { + ERR_PRINT("TinyEXR: G channel not found.") + // @todo { free exr_image } + return ERR_FILE_CORRUPT; + } - if (idxB == -1) { - ERR_PRINT("TinyEXR: B channel not found.") - // @todo { free exr_image } - return ERR_FILE_CORRUPT; + if (idxB == -1) { + ERR_PRINT("TinyEXR: B channel not found.") + // @todo { free exr_image } + return ERR_FILE_CORRUPT; + } } // EXR image data loaded, now parse it into Godot-friendly image data |