const fix; header guard.
[dcpomatic.git] / src / lib / j2k_image_proxy.cc
index 7dca3d8a9faca7324e49a5bbc32a3c4b2008d6b1..303792b80f406e8e8417e401ed646f3410d10f81 100644 (file)
@@ -28,6 +28,8 @@
 #include <dcp/colour_conversion.h>
 #include <dcp/rgb_xyz.h>
 #include <libcxml/cxml.h>
+#include <libxml++/libxml++.h>
+#include <iostream>
 
 #include "i18n.h"
 
@@ -35,6 +37,7 @@ using std::string;
 using std::cout;
 using boost::shared_ptr;
 using boost::optional;
+using boost::dynamic_pointer_cast;
 
 /** Construct a J2KImageProxy from a JPEG2000 file */
 J2KImageProxy::J2KImageProxy (boost::filesystem::path path, dcp::Size size)
@@ -111,7 +114,7 @@ J2KImageProxy::image (optional<dcp::NoteHandler> note) const
        } else {
                dcp::xyz_to_rgb (oj, dcp::ColourConversion::srgb_to_xyz(), image->data()[0], image->stride()[0], note);
        }
-       
+
        return image;
 }
 
@@ -132,3 +135,25 @@ J2KImageProxy::send_binary (shared_ptr<Socket> socket) const
 {
        socket->write (_data.data().get(), _data.size());
 }
+
+bool
+J2KImageProxy::same (shared_ptr<const ImageProxy> other) const
+{
+       shared_ptr<const J2KImageProxy> jp = dynamic_pointer_cast<const J2KImageProxy> (other);
+       if (!jp) {
+               return false;
+       }
+
+       if (_data.size() != jp->_data.size()) {
+               return false;
+       }
+
+       return memcmp (_data.data().get(), jp->_data.data().get(), _data.size()) == 0;
+}
+
+J2KImageProxy::J2KImageProxy (Data data, dcp::Size size)
+       : _data (data)
+       , _size (size)
+{
+
+}