diff Orthanc/Core/Images/ImageAccessor.cpp @ 145:d850500b8ca6

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 08 Nov 2016 10:15:05 +0100
parents 2c73a785c08e
children 5dc54316d68b
line wrap: on
line diff
--- a/Orthanc/Core/Images/ImageAccessor.cpp	Fri Sep 16 09:19:10 2016 +0200
+++ b/Orthanc/Core/Images/ImageAccessor.cpp	Tue Nov 08 10:15:05 2016 +0100
@@ -275,4 +275,22 @@
     return result;
   }
 
+
+  void ImageAccessor::SetFormat(PixelFormat format)
+  {
+    if (readOnly_)
+    {
+#if ORTHANC_ENABLE_LOGGING == 1
+      LOG(ERROR) << "Trying to modify the format of a read-only image";
+#endif
+      throw OrthancException(ErrorCode_ReadOnly);
+    }
+
+    if (::Orthanc::GetBytesPerPixel(format) != ::Orthanc::GetBytesPerPixel(format_))
+    {
+      throw OrthancException(ErrorCode_IncompatibleImageFormat);
+    }
+
+    format_ = format;
+  }
 }