diff Core/Images/ImageAccessor.cpp @ 2103:a89ca69ec1d1

ImageAccessor::SetFormat
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 13 Oct 2016 11:42:30 +0200
parents e2a3ff770b48
children a3a65de1840f
line wrap: on
line diff
--- a/Core/Images/ImageAccessor.cpp	Wed Oct 12 19:35:31 2016 +0200
+++ b/Core/Images/ImageAccessor.cpp	Thu Oct 13 11:42:30 2016 +0200
@@ -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;
+  }
 }