diff Core/Images/PixelTraits.h @ 2493:5aa787a03e7d

PixelTraits::FloatToPixel for color formats
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 15 Mar 2018 16:17:01 +0100
parents e91bab2d8c75
children 89b789366596
line wrap: on
line diff
--- a/Core/Images/PixelTraits.h	Thu Mar 15 11:57:09 2018 +0100
+++ b/Core/Images/PixelTraits.h	Thu Mar 15 16:17:01 2018 +0100
@@ -190,6 +190,18 @@
               a.green_ == b.green_ &&
               a.blue_ == b.blue_);
     }
+
+    ORTHANC_FORCE_INLINE
+    static void FloatToPixel(PixelType& target,
+                             float value)
+    {
+      uint8_t v;
+      PixelTraits<PixelFormat_Grayscale8>::FloatToPixel(v, value);
+
+      target.red_ = v;
+      target.green_ = v;
+      target.blue_ = v;
+    }
   };
 
 
@@ -238,5 +250,18 @@
               a.red_ == b.red_ &&
               a.alpha_ == b.alpha_);
     }
+
+    ORTHANC_FORCE_INLINE
+    static void FloatToPixel(PixelType& target,
+                             float value)
+    {
+      uint8_t v;
+      PixelTraits<PixelFormat_Grayscale8>::FloatToPixel(v, value);
+
+      target.blue_ = v;
+      target.green_ = v;
+      target.red_ = v;
+      target.alpha_ = 255;      
+    }
   };
 }