throw NetworkError (_("Unexpected image type received by server"));
}
-
-bool
-ImageProxy::same (shared_ptr<const ImageProxy> other) const
-{
- return image()->digest() == other->image()->digest();
-}
virtual void add_metadata (xmlpp::Node *) const = 0;
virtual void send_binary (boost::shared_ptr<Socket>) const = 0;
/** @return true if our image is definitely the same as another, false if it is probably not */
- virtual bool same (boost::shared_ptr<const ImageProxy>) const;
+ virtual bool same (boost::shared_ptr<const ImageProxy>) const = 0;
};
boost::shared_ptr<ImageProxy> image_proxy_factory (boost::shared_ptr<cxml::Node> xml, boost::shared_ptr<Socket> socket);
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)
{
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;
+}
boost::shared_ptr<Image> image (boost::optional<dcp::NoteHandler> note = boost::optional<dcp::NoteHandler> ()) const;
void add_metadata (xmlpp::Node *) const;
void send_binary (boost::shared_ptr<Socket>) const;
+ /** @return true if our image is definitely the same as another, false if it is probably not */
+ virtual bool same (boost::shared_ptr<const ImageProxy>) const;
Data j2k () const {
return _data;