2 Copyright (C) 2021 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "pixel_quanta.h"
23 #include <dcp/raw_convert.h>
26 PixelQuanta::PixelQuanta (cxml::ConstNodePtr node)
27 : x(node->number_child<int>("X"))
28 , y(node->number_child<int>("Y"))
35 PixelQuanta::as_xml (xmlpp::Element* node) const
37 node->add_child("X")->add_child_text(dcp::raw_convert<std::string>(x));
38 node->add_child("Y")->add_child_text(dcp::raw_convert<std::string>(y));
43 PixelQuanta::round_x (int x_) const
50 PixelQuanta::round_y (int y_) const
57 PixelQuanta::round (dcp::Size size) const
59 return dcp::Size (round_x(size.width), round_y(size.height));
64 max (PixelQuanta const& a, PixelQuanta const& b)
66 return { std::max(a.x, b.x), std::max(a.y, b.y) };