diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2018-03-13 11:13:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-13 11:13:13 +0100 |
commit | 7463928d0e0a382e8de49bbd1069c1cba28c0d13 (patch) | |
tree | f10663bc8aae5cca693be701c0fbb93c4bc7d03b | |
parent | 08415d0f53ba0f4a6f0b500454d8268c57a598a4 (diff) | |
parent | 886156da2ca14bfdd7e06858bfc25f6507944d38 (diff) |
Merge pull request #17454 from jvdnbus/hdr-import
Fixes importing hdr files with extra header info
-rw-r--r-- | modules/hdr/image_loader_hdr.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/modules/hdr/image_loader_hdr.cpp b/modules/hdr/image_loader_hdr.cpp index 3cc362b5d6..d592c19b97 100644 --- a/modules/hdr/image_loader_hdr.cpp +++ b/modules/hdr/image_loader_hdr.cpp @@ -42,14 +42,18 @@ Error ImageLoaderHDR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force ERR_FAIL_COND_V(header != "#?RADIANCE" && header != "#?RGBE", ERR_FILE_UNRECOGNIZED); while (true) { - String format = f->get_token(); + String line = f->get_line(); ERR_FAIL_COND_V(f->eof_reached(), ERR_FILE_UNRECOGNIZED); - if (format.begins_with("FORMAT=") && format != "FORMAT=32-bit_rle_rgbe") { - ERR_EXPLAIN("Only 32-bit_rle_rgbe is supported for .hdr files."); - return ERR_FILE_UNRECOGNIZED; - } - if (format == "FORMAT=32-bit_rle_rgbe") + if (line == "") // empty line indicates end of header break; + if (line.begins_with("FORMAT=")) { // leave option to implement other commands + if (line != "FORMAT=32-bit_rle_rgbe") { + ERR_EXPLAIN("Only 32-bit_rle_rgbe is supported for HDR files."); + return ERR_FILE_UNRECOGNIZED; + } + } else if (!line.begins_with("#")) { // not comment + WARN_PRINTS("Ignoring unsupported header information in HDR : " + line); + } } String token = f->get_token(); |