changeset 342:39936650edc1

simplification
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 10 Dec 2024 12:57:40 +0100
parents f14e81852a6c
children af8ebf590a29
files Framework/Inputs/OnTheFlyPyramid.cpp
diffstat 1 files changed, 9 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Inputs/OnTheFlyPyramid.cpp	Sat Dec 07 15:05:17 2024 +0100
+++ b/Framework/Inputs/OnTheFlyPyramid.cpp	Tue Dec 10 12:57:40 2024 +0100
@@ -43,41 +43,19 @@
 
     const Orthanc::ImageAccessor& source = GetLevel(level);
 
-    unsigned int fromWidth;
-    if (x + tileWidth_ <= source.GetWidth())
-    {
-      fromWidth = tileWidth_;
-    }
-    else
+    if (target.GetWidth() > tileWidth_ ||
+      target.GetHeight() > tileHeight_ ||
+      x + target.GetWidth() > source.GetWidth() ||
+      y + target.GetHeight() > source.GetHeight())
     {
-      fromWidth = source.GetWidth() - x;
-    }
-
-    unsigned int fromHeight;
-    if (y + tileHeight_ <= source.GetHeight())
-    {
-      fromHeight = tileHeight_;
+      // This should be handled by the base class
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
     }
     else
     {
-      fromHeight = source.GetHeight() - y;
-    }
-
-    if (fromWidth == tileWidth_ &&
-        fromHeight == tileHeight_)
-    {
-      source.GetRegion(target, x, y, tileWidth_, tileHeight_);
-    }
-    else
-    {
-      uint8_t red, green, blue;
-      GetBackgroundColor(red, green, blue);
-      Orthanc::ImageProcessing::Set(target, red, green, blue, 255);
-
-      Orthanc::ImageAccessor from, to;
-      source.GetRegion(from, x, y, fromWidth, fromHeight);
-      target.GetRegion(to, 0, 0, fromWidth, fromHeight);
-      Orthanc::ImageProcessing::Copy(to, from);
+      Orthanc::ImageAccessor from;
+      source.GetRegion(from, x, y, target.GetWidth(), target.GetHeight());
+      Orthanc::ImageProcessing::Copy(target, from);
     }
   }