changeset 2103:a89ca69ec1d1

ImageAccessor::SetFormat
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 13 Oct 2016 11:42:30 +0200
parents f0544ab9396b
children 58a0ee0b4be1
files Core/Images/ImageAccessor.cpp Core/Images/ImageAccessor.h
diffstat 2 files changed, 20 insertions(+), 0 deletions(-) [+]
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;
+  }
 }
--- a/Core/Images/ImageAccessor.h	Wed Oct 12 19:35:31 2016 +0200
+++ b/Core/Images/ImageAccessor.h	Thu Oct 13 11:42:30 2016 +0200
@@ -125,5 +125,7 @@
                             unsigned int y,
                             unsigned int width,
                             unsigned int height) const;
+
+    void SetFormat(PixelFormat format);
   };
 }