diff Framework/Volumes/ImageBuffer3D.cpp @ 141:88bca952cb17 wasm

ImageBuffer3D::GetPixelGrayscale8
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 18 Jan 2018 17:23:21 +0100
parents 22628d37ef5c
children 58c545177c1c
line wrap: on
line diff
--- a/Framework/Volumes/ImageBuffer3D.cpp	Thu Jan 18 14:42:33 2018 +0100
+++ b/Framework/Volumes/ImageBuffer3D.cpp	Thu Jan 18 17:23:21 2018 +0100
@@ -422,6 +422,28 @@
   }
 
 
+  uint8_t ImageBuffer3D::GetPixelGrayscale8(unsigned int x,
+                                            unsigned int y,
+                                            unsigned int z) const
+  {
+    if (format_ != Orthanc::PixelFormat_Grayscale8)
+    {
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
+    }
+
+    if (x >= width_ ||
+        y >= height_ ||
+        z >= depth_)
+    {
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
+    }
+
+    const void* p = image_.GetConstRow(y + height_ * (depth_ - 1 - z));
+
+    return reinterpret_cast<const uint8_t*>(p) [x];
+  }
+
+
   uint16_t ImageBuffer3D::GetPixelGrayscale16(unsigned int x,
                                               unsigned int y,
                                               unsigned int z) const
@@ -442,5 +464,4 @@
 
     return reinterpret_cast<const uint16_t*>(p) [x];
   }
-
 }