Skip to content

Commit bd93744

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

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

src/libOpenImageIO/formatspec.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,11 +1288,12 @@ ImageSpec::set_cicp(string_view cicp)
12881288
erase_attribute("oiio:CICP");
12891289
return;
12901290
}
1291-
auto vals = Strutil::extract_from_list_string<int>("0,0,0,1", 4, 0);
1292-
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);
1291+
std::vector<int> vals { 0, 0, 0, 1 };
1292+
auto p = find_attribute("oiio:CICP", TypeDesc(TypeDesc::UINT8, 4));
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)