diff Core/Images/ImageProcessing.cpp @ 2281:e002430baa41

Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 09 Jun 2017 16:14:52 +0200
parents 002b94046c69
children 7e217a1cc63f
line wrap: on
line diff
--- a/Core/Images/ImageProcessing.cpp	Mon May 22 20:39:53 2017 +0200
+++ b/Core/Images/ImageProcessing.cpp	Fri Jun 09 16:14:52 2017 +0200
@@ -772,4 +772,29 @@
         throw OrthancException(ErrorCode_NotImplemented);
     }
   }
+
+
+  void ImageProcessing::Invert(ImageAccessor& image)
+  {
+    switch (image.GetFormat())
+    {
+      case PixelFormat_Grayscale8:
+      {
+        for (unsigned int y = 0; y < image.GetHeight(); y++)
+        {
+          uint8_t* p = reinterpret_cast<uint8_t*>(image.GetRow(y));
+
+          for (unsigned int x = 0; x < image.GetWidth(); x++, p++)
+          {
+            *p = 255 - (*p);
+          }
+        }
+        
+        return;
+      }
+
+      default:
+        throw OrthancException(ErrorCode_NotImplemented);
+    }   
+  }
 }