diff Core/Images/PixelTraits.h @ 2649:193ef9c1b731 jobs

integration mainline->jobs
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 01 Jun 2018 10:51:06 +0200
parents 89b789366596
children 65699fcb4e99
line wrap: on
line diff
--- a/Core/Images/PixelTraits.h	Thu May 31 18:44:05 2018 +0200
+++ b/Core/Images/PixelTraits.h	Fri Jun 01 10:51:06 2018 +0200
@@ -150,6 +150,20 @@
 
 
   template <>
+  struct PixelTraits<PixelFormat_Grayscale32> :
+    public IntegerPixelTraits<PixelFormat_Grayscale32, uint32_t>
+  {
+  };
+
+
+  template <>
+  struct PixelTraits<PixelFormat_Grayscale64> :
+    public IntegerPixelTraits<PixelFormat_Grayscale64, uint64_t>
+  {
+  };
+
+
+  template <>
   struct PixelTraits<PixelFormat_RGB24>
   {
     struct PixelType
@@ -264,4 +278,57 @@
       target.alpha_ = 255;      
     }
   };
+
+
+  template <>
+  struct PixelTraits<PixelFormat_Float32>
+  {
+    typedef float  PixelType;
+
+    ORTHANC_FORCE_INLINE
+    static PixelFormat GetPixelFormat()
+    {
+      return PixelFormat_Float32;
+    }
+
+    ORTHANC_FORCE_INLINE
+    static void SetZero(PixelType& target)
+    {
+      target = 0.0f;
+    }
+
+    ORTHANC_FORCE_INLINE
+    static void Copy(PixelType& target,
+                     const PixelType& source)
+    {
+      target = source;
+    }
+
+    ORTHANC_FORCE_INLINE
+    static bool IsEqual(const PixelType& a,
+                        const PixelType& b)
+    {
+      float tmp = (a - b);
+
+      if (tmp < 0)
+      {
+        tmp = -tmp;
+      }
+
+      return tmp <= std::numeric_limits<float>::epsilon();
+    }
+    
+    ORTHANC_FORCE_INLINE
+    static void FloatToPixel(PixelType& target,
+                             float value)
+    {
+      target = value;
+    }
+
+    ORTHANC_FORCE_INLINE
+    static float PixelToFloat(const PixelType& source)
+    {
+      return source;
+    }
+  };
 }