# HG changeset patch
# User Sebastien Jodogne <s.jodogne@gmail.com>
# Date 1538755015 -7200
# Node ID 0f07bdae08057971112633a22f3b3e9b27131b23
# Parent  7cac2bc1986e9762ce24d61505f207f8a750c35c
ImageAccessor::GetWriteableAccessor() and GetReadOnlyAccessor()

diff -r 7cac2bc1986e -r 0f07bdae0805 Core/Images/ImageAccessor.cpp
--- a/Core/Images/ImageAccessor.cpp	Fri Oct 05 17:51:10 2018 +0200
+++ b/Core/Images/ImageAccessor.cpp	Fri Oct 05 17:56:55 2018 +0200
@@ -204,6 +204,19 @@
   }
 
 
+  void ImageAccessor::GetWriteableAccessor(ImageAccessor& target) const
+  {
+    if (readOnly_)
+    {
+      throw OrthancException(ErrorCode_ReadOnly);
+    }
+    else
+    {
+      target.AssignWritable(format_, width_, height_, pitch_, buffer_);
+    }
+  }
+
+
   void ImageAccessor::ToMatlabString(std::string& target) const
   {
     ChunkedBuffer buffer;
diff -r 7cac2bc1986e -r 0f07bdae0805 Core/Images/ImageAccessor.h
--- a/Core/Images/ImageAccessor.h	Fri Oct 05 17:51:10 2018 +0200
+++ b/Core/Images/ImageAccessor.h	Fri Oct 05 17:56:55 2018 +0200
@@ -135,12 +135,19 @@
                         unsigned int pitch,
                         const void *buffer);
 
+    void GetReadOnlyAccessor(ImageAccessor& target) const
+    {
+      target.AssignReadOnly(format_, width_, height_, pitch_, buffer_);
+    }
+
     void AssignWritable(PixelFormat format,
                         unsigned int width,
                         unsigned int height,
                         unsigned int pitch,
                         void *buffer);
 
+    void GetWriteableAccessor(ImageAccessor& target) const;
+
     void ToMatlabString(std::string& target) const; 
 
     void GetRegion(ImageAccessor& accessor,