WIP: partially restore PlayerVideo transfer over network.
[dcpomatic.git] / src / lib / bitmap_text.cc
1 /*
2     Copyright (C) 2014-2019 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
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.
10
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.
15
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/>.
18
19 */
20
21 #include "bitmap_text.h"
22 #include "image.h"
23 #include "dcpomatic_socket.h"
24 #include <dcp/raw_convert.h>
25
26 using boost::shared_ptr;
27 using dcp::raw_convert;
28
29 bool
30 operator== (BitmapText const & a, BitmapText const & b)
31 {
32         if (!a.rectangle.equal(b.rectangle, 0.000001)) {
33                 return false;
34         }
35
36         return *a.image == *b.image;
37 }
38
39 bool
40 operator!= (BitmapText const & a, BitmapText const & b)
41 {
42         return !(a == b);
43 }
44
45 void
46 BitmapText::transfer_xml (xmlpp::Node* node) const
47 {
48         node->add_child("Width")->add_child_text(raw_convert<std::string>(image->size().width));
49         node->add_child("Height")->add_child_text(raw_convert<std::string>(image->size().height));
50         node->add_child("RectX")->add_child_text(raw_convert<std::string>(rectangle.x));
51         node->add_child("RectY")->add_child_text(raw_convert<std::string>(rectangle.y));
52         node->add_child("RectWidth")->add_child_text(raw_convert<std::string>(rectangle.width));
53         node->add_child("RectHeight")->add_child_text(raw_convert<std::string>(rectangle.height));
54 }
55
56 void
57 BitmapText::transfer_binary (shared_ptr<Socket> socket) const
58 {
59         image->write_to_socket (socket);
60 }
61