+ if (!m.empty ()) {
+ /* Read in old <Matrix> nodes and convert them to chromaticities */
+ boost::numeric::ublas::matrix<double> C (3, 3);
+ for (list<cxml::NodePtr>::iterator i = m.begin(); i != m.end(); ++i) {
+ int const ti = (*i)->number_attribute<int> ("i");
+ int const tj = (*i)->number_attribute<int> ("j");
+ C(ti, tj) = raw_convert<double> ((*i)->content ());
+ }
+
+ double const rd = C(0, 0) + C(1, 0) + C(2, 0);
+ _red = dcp::Chromaticity (C(0, 0) / rd, C(1, 0) / rd);
+ double const gd = C(0, 1) + C(1, 1) + C(2, 1);
+ _green = dcp::Chromaticity (C(0, 1) / gd, C(1, 1) / gd);
+ double const bd = C(0, 2) + C(1, 2) + C(2, 2);
+ _blue = dcp::Chromaticity (C(0, 2) / bd, C(1, 2) / bd);
+ double const wd = C(0, 0) + C(0, 1) + C(0, 2) + C(1, 0) + C(1, 1) + C(1, 2) + C(2, 0) + C(2, 1) + C(2, 2);
+ _white = dcp::Chromaticity ((C(0, 0) + C(0, 1) + C(0, 2)) / wd, (C(1, 0) + C(1, 1) + C(1, 2)) / wd);
+ } else {
+ /* New-style chromaticities */
+ _red = dcp::Chromaticity (node->number_child<double> ("RedX"), node->number_child<double> ("RedY"));
+ _green = dcp::Chromaticity (node->number_child<double> ("GreenX"), node->number_child<double> ("GreenY"));
+ _blue = dcp::Chromaticity (node->number_child<double> ("BlueX"), node->number_child<double> ("BlueY"));
+ _white = dcp::Chromaticity (node->number_child<double> ("WhiteX"), node->number_child<double> ("WhiteY"));
+ if (node->optional_node_child ("AdjustedWhiteX")) {
+ _adjusted_white = dcp::Chromaticity (
+ node->number_child<double> ("AdjustedWhiteX"), node->number_child<double> ("AdjustedWhiteY")
+ );
+ }