Skip to content

Commit 3a0c900

Browse files
committed
fix: simplify ImageSpec::set_cicp from string method
Signed-off-by: Zach Lewis <zachcanbereached@gmail.com>
1 parent 3982143 commit 3a0c900

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/libOpenImageIO/formatspec.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ ImageSpec::find_attribute(string_view name, ParamValue& tmpparam,
470470
auto iter = extra_attribs.find(name, searchtype, casesensitive);
471471
if (iter != extra_attribs.end())
472472
return &(*iter);
473-
// Check named items in the ImageSpec structs, not in extra_attrubs
473+
// Check named items in the ImageSpec structs, not in extra_attrubs
474474
#define MATCH(n, t) \
475475
(((!casesensitive && Strutil::iequals(name, n)) \
476476
|| (casesensitive && name == n)) \
@@ -1290,9 +1290,10 @@ ImageSpec::set_cicp(string_view cicp)
12901290
}
12911291
auto vals = Strutil::extract_from_list_string<int>("0,0,0,1", 4, 0);
12921292
auto p = find_attribute("oiio:CICP", TypeDesc(TypeDesc::UINT8, 4));
1293-
if (p) {
1294-
string_view existing_vals = metadata_val(*p);
1295-
Strutil::extract_from_list_string<int>(vals, existing_vals);
1293+
if (p && p->type() == TypeDesc(TypeDesc::UINT8, 4) && p->nvalues() == 4) {
1294+
const uint8_t* existing = static_cast<const uint8_t*>(p->data());
1295+
for (int i = 0; i < 4; ++i)
1296+
vals[i] = existing[i];
12961297
}
12971298
Strutil::extract_from_list_string<int>(vals, cicp);
12981299
set_cicp(vals[0], vals[1], vals[2], vals[3]);

testsuite/png/ref/out-libpng15.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ smallalpha.png : 1 x 1, 4 channel, uint8 png
9393
cicp:
9494
16 x 16, 4 channel, float png
9595
channel list: R, G, B, A
96-
Software: "OpenImageIO 3.1.1.0dev : DC4B1085141AF19019744DC43B156DE981E3B465"
96+
Software: "OpenImageIO 3.1.2.0dev : DC4B1085141AF19019744DC43B156DE981E3B465"
9797
oiio:ColorSpace: "sRGB"
9898
Comparing "test16.png" and "ref/test16.png"
9999
PASS

testsuite/png/ref/out.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ smallalpha.png : 1 x 1, 4 channel, uint8 png
9393
cicp:
9494
16 x 16, 4 channel, float png
9595
channel list: R, G, B, A
96-
Software: "OpenImageIO 3.1.1.0dev : DC4B1085141AF19019744DC43B156DE981E3B465"
96+
Software: "OpenImageIO 3.1.2.0dev : DC4B1085141AF19019744DC43B156DE981E3B465"
9797
oiio:CICP: 1, 13, 0, 1
9898
oiio:ColorSpace: "sRGB"
9999
Comparing "test16.png" and "ref/test16.png"

0 commit comments

Comments
 (0)