changeset 2100:1554fc153a93

conversion RGB24 to BGRA32
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 10 Oct 2016 15:55:56 +0200
parents 7d184e11043e
children 0b6464320aac
files Core/Images/ImageProcessing.cpp
diffstat 1 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Core/Images/ImageProcessing.cpp	Thu Oct 06 17:28:43 2016 +0200
+++ b/Core/Images/ImageProcessing.cpp	Mon Oct 10 15:55:56 2016 +0200
@@ -519,6 +519,27 @@
       return;
     }
 
+    if (target.GetFormat() == PixelFormat_BGRA32 &&
+        source.GetFormat() == PixelFormat_RGB24)
+    {
+      for (unsigned int y = 0; y < source.GetHeight(); y++)
+      {
+        const uint8_t* p = reinterpret_cast<const uint8_t*>(source.GetConstRow(y));
+        uint8_t* q = reinterpret_cast<uint8_t*>(target.GetRow(y));
+        for (unsigned int x = 0; x < source.GetWidth(); x++)
+        {
+          q[0] = p[2];
+          q[1] = p[1];
+          q[2] = p[0];
+          q[3] = 255;
+          p += 3;
+          q += 4;
+        }
+      }
+
+      return;
+    }
+
     throw OrthancException(ErrorCode_NotImplemented);
   }