changeset 377:be713f91c3e6

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 05 Apr 2025 14:52:55 +0200 (6 weeks ago)
parents c1838c538510
children e5fb8f7ade59
files ViewerPlugin/OrthancPyramidFrameFetcher.cpp
diffstat 1 files changed, 6 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/ViewerPlugin/OrthancPyramidFrameFetcher.cpp	Sat Apr 05 13:28:04 2025 +0200
+++ b/ViewerPlugin/OrthancPyramidFrameFetcher.cpp	Sat Apr 05 14:52:55 2025 +0200
@@ -168,6 +168,7 @@
         throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
     }
 
+
     std::unique_ptr<Orthanc::ImageAccessor> rendered(new Orthanc::Image(targetFormat, paddedWidth, paddedHeight, false));
 
     if (paddedWidth != frame->GetWidth() ||
@@ -176,29 +177,15 @@
       Orthanc::ImageProcessing::Set(*rendered, backgroundRed, backgroundGreen, backgroundBlue, 255 /* alpha */);
     }
 
-    Orthanc::ImageAccessor target;
-    rendered->GetRegion(target, 0, 0, frame->GetWidth(), frame->GetHeight());
 
-
-    Orthanc::ImageAccessor source;
-    source.AssignReadOnly(sourceFormat, frame->GetWidth(), frame->GetHeight(), frame->GetPitch(), frame->GetBuffer());
-
-    switch (targetFormat)
     {
-      case Orthanc::PixelFormat_RGB24:
-        Orthanc::ImageProcessing::Copy(target, source);
-        break;
+      Orthanc::ImageAccessor target;
+      rendered->GetRegion(target, 0, 0, frame->GetWidth(), frame->GetHeight());
 
-      case Orthanc::PixelFormat_Grayscale8:
-      {
-        double offset, scaling;
-        info.ComputeRenderingTransform(offset, scaling);  // Use the default windowing
-        Orthanc::ImageProcessing::ShiftScale2(target, source, static_cast<float>(offset), static_cast<float>(scaling), false);
-        break;
-      }
+      Orthanc::ImageAccessor source;
+      source.AssignReadOnly(sourceFormat, frame->GetWidth(), frame->GetHeight(), frame->GetPitch(), frame->GetBuffer());
 
-      default:
-        throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
+      Orthanc::ImageProcessing::RenderDefaultWindow(target, info, source);
     }