diff Framework/Inputs/OpenSlidePyramid.cpp @ 317:f611fb47d0e8

reuse base class members in OpenSlidePyramid
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 11 Sep 2024 13:43:39 +0200
parents 072968f00d26
children 8ad12abde290
line wrap: on
line diff
--- a/Framework/Inputs/OpenSlidePyramid.cpp	Mon Sep 09 20:13:36 2024 +0200
+++ b/Framework/Inputs/OpenSlidePyramid.cpp	Wed Sep 11 13:43:39 2024 +0200
@@ -55,6 +55,10 @@
         source->GetFormat() == Orthanc::PixelFormat_BGRA32)
     {
       // Implements alpha blending: https://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending
+
+      uint8_t backgroundRed, backgroundGreen, backgroundBlue;
+      GetBackgroundColor(backgroundRed, backgroundGreen, backgroundBlue);
+
       for (unsigned int y = 0; y < height; y++)
       {
         const uint8_t* p = reinterpret_cast<const uint8_t*>(source->GetConstRow(y));
@@ -71,9 +75,9 @@
            **/
 
           uint16_t alpha = p[3];
-          q[0] = static_cast<uint8_t>(((255 - alpha) * backgroundColor_[0] + alpha * p[2]) / 255);
-          q[1] = static_cast<uint8_t>(((255 - alpha) * backgroundColor_[1] + alpha * p[1]) / 255);
-          q[2] = static_cast<uint8_t>(((255 - alpha) * backgroundColor_[2] + alpha * p[0]) / 255);
+          q[0] = static_cast<uint8_t>(((255 - alpha) * backgroundRed + alpha * p[2]) / 255);
+          q[1] = static_cast<uint8_t>(((255 - alpha) * backgroundGreen + alpha * p[1]) / 255);
+          q[2] = static_cast<uint8_t>(((255 - alpha) * backgroundBlue + alpha * p[0]) / 255);
 
           p += 4;
           q += 3;
@@ -94,9 +98,6 @@
     tileWidth_(tileWidth),
     tileHeight_(tileHeight)
   {
-    backgroundColor_[0] = 255;
-    backgroundColor_[1] = 255;
-    backgroundColor_[2] = 255;
   }
 
 
@@ -122,14 +123,4 @@
       return false;
     }
   }
-
-
-  void OpenSlidePyramid::SetBackgroundColor(uint8_t red,
-                                            uint8_t green,
-                                            uint8_t blue)
-  {
-    backgroundColor_[0] = red;
-    backgroundColor_[1] = green;
-    backgroundColor_[2] = blue;
-  }
 }