changeset 2493:5aa787a03e7d

PixelTraits::FloatToPixel for color formats
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 15 Mar 2018 16:17:01 +0100
parents 58c50d627b2f
children 771c1c14628c
files Core/Images/PixelTraits.h
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
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;      
+    }
   };
 }