Commit 9b881f73 authored by PACANOWSKI Romain's avatar PACANOWSKI Romain
Browse files

Merge branch 'af_fix_spectral_exr_v1.0' into 'master'

Update Spectral EXR specs

See merge request !207
parents 37b19e10 65970bf7
Pipeline #261220 failed with stages
in 28 minutes and 31 seconds
......@@ -441,25 +441,35 @@ IMAGE_LOAD_SAVE_FLAGS EXRSpectralImage::save(
// We need C style allocation to comply with TinyEXR free functions
// Add custom attributes
header.num_custom_attributes = 2;
if (additional_comments != "")
{
//ADD in the Header the additional_information string
header.num_custom_attributes = 1;
header.custom_attributes = (EXRAttribute *)malloc(sizeof(EXRAttribute));
header.num_custom_attributes++;
}
header.custom_attributes = (EXRAttribute *)calloc(header.num_custom_attributes, sizeof(EXRAttribute));
EXRAttribute &attrib = header.custom_attributes[0];
std::function<void(EXRAttribute &, const char *, const char *)> writeStringAttr
= [this](EXRAttribute &attribute, const char *attrName, const char *attrValue) {
strcpy(attribute.name, attrName);
strcpy(attribute.type, "string");
std::string const mrf_info = "mrf_additional_information";
strcpy(attrib.name, mrf_info.c_str());
attribute.size = static_cast<int>(strlen(attrValue) + 1);
attribute.value = (unsigned char *)calloc(attribute.size, sizeof(unsigned char));
memcpy(attribute.value, attrValue, attribute.size * sizeof(char));
};
std::string const mrf_info_type = "string";
strcpy(attrib.type, mrf_info_type.c_str());
// Mandatory field to specify the layout version
writeStringAttr(header.custom_attributes[0], "spectralLayoutVersion", "1.0");
attrib.size = static_cast<int>(additional_comments.size());
// Mandatory field to specify radiometric units
writeStringAttr(header.custom_attributes[1], "emissiveUnits", "W.m^-2.sr^-1");
unsigned char *tmp_ptr = (unsigned char *)calloc(additional_comments.size(), sizeof(unsigned char));
attrib.value = tmp_ptr;
memcpy(attrib.value, additional_comments.data(), attrib.size * sizeof(unsigned char));
if (additional_comments != "")
{
// Add in the Header the additional_information string
writeStringAttr(header.custom_attributes[2], "mrfAdditionalInformation", additional_comments.c_str());
}
EXRImage image;
......@@ -518,7 +528,7 @@ IMAGE_LOAD_SAVE_FLAGS EXRSpectralImage::save(
}
// Write B, G, R instead of R, G, B.
// Most of EXR viewers expect this channel order.
// OpenEXR official library sorts layers alphabetically
std::swap(images[0], images[2]);
for (size_t i = 0; i < _wavelengths.size(); i++)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment