Skip to content

Commit c5bdab3

Browse files
committed
Allow lowercase r,g and b, and reg, greee and blue.
1 parent 1aaa178 commit c5bdab3

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/lib/OpenEXRCore/internal_ht_common.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <vector>
88
#include <string>
99
#include <cassert>
10+
#include <algorithm>
11+
#include <cctype>
1012

1113
bool
1214
make_channel_map (
@@ -22,9 +24,13 @@ make_channel_map (
2224
{
2325
std::string c_name(channels[i].channel_name);
2426

25-
if (c_name == "R") { r_index = i; }
26-
else if (c_name == "G") { g_index = i; }
27-
else if (c_name == "B") { b_index = i; }
27+
/* heuristics to determine whether RGB channels are present */
28+
std::transform(c_name.begin(), c_name.end(), c_name.begin(),
29+
[](unsigned char c){ return std::tolower(c); });
30+
31+
if (c_name == "r" || c_name.compare(0, 3, "red") == 0) { r_index = i; }
32+
else if (c_name == "g" || c_name.compare(0, 5, "green") == 0) { g_index = i; }
33+
else if (c_name == "b" || c_name.compare(0, 4, "blue")== 0) { b_index = i; }
2834
}
2935

3036
bool isRGB = r_index >= 0 && g_index >= 0 && b_index >= 0 &&

0 commit comments

Comments
 (0)