diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-07-09 17:05:26 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-07-09 17:05:26 +0100 |
| commit | 63f506966cc4e9c459b3bcb430a11481f9d3a24a (patch) | |
| tree | cdaf50ec415c57940dccbd4ba35c091e33303cc2 /src/lib/raw_image_proxy.cc | |
| parent | 424f9d0c70ff0832da0509776da939b2f855cdc1 (diff) | |
Split up image_proxy.{cc,h}
Diffstat (limited to 'src/lib/raw_image_proxy.cc')
| -rw-r--r-- | src/lib/raw_image_proxy.cc | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/lib/raw_image_proxy.cc b/src/lib/raw_image_proxy.cc new file mode 100644 index 000000000..7e0688d13 --- /dev/null +++ b/src/lib/raw_image_proxy.cc @@ -0,0 +1,71 @@ +/* + Copyright (C) 2014 Carl Hetherington <cth@carlh.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +extern "C" { +#include <libavutil/pixfmt.h> +} +#include <libcxml/cxml.h> +#include <dcp/util.h> +#include <dcp/raw_convert.h> +#include "raw_image_proxy.h" +#include "image.h" + +#include "i18n.h" + +using std::string; +using boost::shared_ptr; + +RawImageProxy::RawImageProxy (shared_ptr<Image> image, shared_ptr<Log> log) + : ImageProxy (log) + , _image (image) +{ + +} + +RawImageProxy::RawImageProxy (shared_ptr<cxml::Node> xml, shared_ptr<Socket> socket, shared_ptr<Log> log) + : ImageProxy (log) +{ + dcp::Size size ( + xml->number_child<int> ("Width"), xml->number_child<int> ("Height") + ); + + _image.reset (new Image (static_cast<AVPixelFormat> (xml->number_child<int> ("PixelFormat")), size, true)); + _image->read_from_socket (socket); +} + +shared_ptr<Image> +RawImageProxy::image () const +{ + return _image; +} + +void +RawImageProxy::add_metadata (xmlpp::Node* node) const +{ + node->add_child("Type")->add_child_text (N_("Raw")); + node->add_child("Width")->add_child_text (dcp::raw_convert<string> (_image->size().width)); + node->add_child("Height")->add_child_text (dcp::raw_convert<string> (_image->size().height)); + node->add_child("PixelFormat")->add_child_text (dcp::raw_convert<string> (_image->pixel_format ())); +} + +void +RawImageProxy::send_binary (shared_ptr<Socket> socket) const +{ + _image->write_to_socket (socket); +} |
