Merge pull request #27327 from goodyttoor/grayscale_exr

Fix import grayscale EXR
This commit is contained in:
Rémi Verschelde 2019-04-05 15:46:23 +02:00 committed by GitHub
commit c9aa0c20a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 14 deletions

View File

@ -107,6 +107,14 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
} }
} }
if (exr_header.num_channels == 1) {
// Grayscale channel only.
idxR = 0;
idxG = 0;
idxB = 0;
idxA = 0;
} else {
// Assume RGB(A)
if (idxR == -1) { if (idxR == -1) {
ERR_PRINT("TinyEXR: R channel not found."); ERR_PRINT("TinyEXR: R channel not found.");
// @todo { free exr_image } // @todo { free exr_image }
@ -124,6 +132,7 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
// @todo { free exr_image } // @todo { free exr_image }
return ERR_FILE_CORRUPT; return ERR_FILE_CORRUPT;
} }
}
// EXR image data loaded, now parse it into Godot-friendly image data // EXR image data loaded, now parse it into Godot-friendly image data