bool OpenEXROutput::put_parameter (const std::string &name, TypeDesc type, const void *data) { // Translate std::string xname = name; if (istarts_with (xname, "oiio:")) return false; else if (iequals(xname, "worldtocamera")) xname = "worldToCamera"; else if (iequals(xname, "worldtoscreen")) xname = "worldToNDC"; else if (iequals(xname, "DateTime")) xname = "capDate"; else if (iequals(xname, "description") || iequals(xname, "ImageDescription")) xname = "comments"; else if (iequals(xname, "Copyright")) xname = "owner"; else if (iequals(xname, "PixelAspectRatio")) xname = "pixelAspectRatio"; else if (iequals(xname, "ExposureTime")) xname = "expTime"; else if (iequals(xname, "FNumber")) xname = "aperture"; else if (istarts_with (xname, format_prefix)) xname = std::string (xname.begin()+format_prefix.size(), xname.end()); // std::cerr << "exr put '" << name << "' -> '" << xname << "'\n"; // Special cases if (iequals(xname, "Compression") && type == TypeDesc::STRING) { const char *str = *(char **)data; m_header->compression() = Imf::ZIP_COMPRESSION; // Default if (str) { if (iequals (str, "none")) m_header->compression() = Imf::NO_COMPRESSION; else if (iequals (str, "deflate") || iequals (str, "zip")) m_header->compression() = Imf::ZIP_COMPRESSION; else if (iequals (str, "rle")) m_header->compression() = Imf::RLE_COMPRESSION; else if (iequals (str, "zips")) m_header->compression() = Imf::ZIPS_COMPRESSION; else if (iequals (str, "piz")) m_header->compression() = Imf::PIZ_COMPRESSION; else if (iequals (str, "pxr24")) m_header->compression() = Imf::PXR24_COMPRESSION; #ifdef IMF_B44_COMPRESSION // The enum Imf::B44_COMPRESSION is not defined in older versions // of OpenEXR, and there are no explicit version numbers in the // headers. BUT this other related #define is present only in // the newer version. else if (iequals (str, "b44")) m_header->compression() = Imf::B44_COMPRESSION; else if (iequals (str, "b44a")) m_header->compression() = Imf::B44A_COMPRESSION; #endif } return true; } if (iequals (xname, "openexr:lineOrder") && type == TypeDesc::STRING) { const char *str = *(char **)data; m_header->lineOrder() = Imf::INCREASING_Y; // Default if (str) { if (iequals (str, "randomY")) m_header->lineOrder() = Imf::RANDOM_Y; else if (iequals (str, "decreasingY")) m_header->lineOrder() = Imf::DECREASING_Y; } return true; } // Supress planarconfig! if (iequals (xname, "planarconfig") || iequals (xname, "tiff:planarconfig")) return true; // General handling of attributes // FIXME -- police this if we ever allow arrays if (type == TypeDesc::INT || type == TypeDesc::UINT) { m_header->insert (xname.c_str(), Imf::IntAttribute (*(int*)data)); return true; } if (type == TypeDesc::INT16) { m_header->insert (xname.c_str(), Imf::IntAttribute (*(short*)data)); return true; } if (type == TypeDesc::UINT16) { m_header->insert (xname.c_str(), Imf::IntAttribute (*(unsigned short*)data)); return true; } if (type == TypeDesc::FLOAT) { m_header->insert (xname.c_str(), Imf::FloatAttribute (*(float*)data)); return true; } if (type == TypeDesc::HALF) { m_header->insert (xname.c_str(), Imf::FloatAttribute ((float)*(half*)data)); return true; } if (type == TypeDesc::TypeMatrix) { m_header->insert (xname.c_str(), Imf::M44fAttribute (*(Imath::M44f*)data)); return true; } if (type == TypeDesc::TypeString) { m_header->insert (xname.c_str(), Imf::StringAttribute (*(char**)data)); return true; } if (type == TypeDesc::TypeVector) { m_header->insert (xname.c_str(), Imf::V3fAttribute (*(Imath::V3f*)data)); return true; } #ifdef DEBUG std::cerr << "Don't know what to do with " << type.c_str() << ' ' << xname << "\n"; #endif return false; }