changeset 2783:65699fcb4e99

PixelTraits<PixelFormat_RGBA32>
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 24 Jul 2018 15:00:58 +0200
parents 64e3d4ab158d
children 167105b5b48e
files Core/Images/ImageProcessing.cpp Core/Images/PixelTraits.h
diffstat 2 files changed, 74 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Core/Images/ImageProcessing.cpp	Tue Jul 24 10:39:08 2018 +0200
+++ b/Core/Images/ImageProcessing.cpp	Tue Jul 24 15:00:58 2018 +0200
@@ -1219,6 +1219,19 @@
         break;
       }
         
+      case Orthanc::PixelFormat_RGBA32:
+      {
+        PixelTraits<Orthanc::PixelFormat_RGBA32>::PixelType pixel;
+        pixel.red_ = red;
+        pixel.green_ = green;
+        pixel.blue_ = blue;
+        pixel.alpha_ = alpha;
+
+        BresenhamPixelWriter<Orthanc::PixelFormat_RGBA32> writer(image, pixel);
+        writer.DrawSegment(x0, y0, x1, y1);
+        break;
+      }
+        
       case Orthanc::PixelFormat_RGB24:
       {
         PixelTraits<Orthanc::PixelFormat_RGB24>::PixelType pixel;
--- a/Core/Images/PixelTraits.h	Tue Jul 24 10:39:08 2018 +0200
+++ b/Core/Images/PixelTraits.h	Tue Jul 24 15:00:58 2018 +0200
@@ -281,6 +281,67 @@
 
 
   template <>
+  struct PixelTraits<PixelFormat_RGBA32>
+  {
+    struct PixelType
+    {
+      uint8_t  red_;
+      uint8_t  green_;
+      uint8_t  blue_;
+      uint8_t  alpha_;
+    };
+
+    ORTHANC_FORCE_INLINE
+    static PixelFormat GetPixelFormat()
+    {
+      return PixelFormat_RGBA32;
+    }
+
+    ORTHANC_FORCE_INLINE
+    static void SetZero(PixelType& target)
+    {
+      target.red_ = 0;
+      target.green_ = 0;
+      target.blue_ = 0;
+      target.alpha_ = 0;
+    }
+
+    ORTHANC_FORCE_INLINE
+    static void Copy(PixelType& target,
+                     const PixelType& source)
+    {
+      target.red_ = source.red_;
+      target.green_ = source.green_;
+      target.blue_ = source.blue_;
+      target.alpha_ = source.alpha_;
+    }
+
+    ORTHANC_FORCE_INLINE
+    static bool IsEqual(const PixelType& a,
+                        const PixelType& b)
+    {
+      return (a.red_ == b.red_ &&
+              a.green_ == b.green_ &&
+              a.blue_ == b.blue_ &&
+              a.alpha_ == b.alpha_);
+    }
+
+    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;
+      target.alpha_ = 255;      
+    }
+  };
+
+
+  template <>
   struct PixelTraits<PixelFormat_Float32>
   {
     typedef float  PixelType;