diff Framework/Toolbox/OrthancSlicesLoader.cpp @ 203:431e991af593

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 27 Mar 2018 11:12:50 +0200
parents e9c7a78a3e77
children 5412adf19980
line wrap: on
line diff
--- a/Framework/Toolbox/OrthancSlicesLoader.cpp	Mon Mar 26 18:10:34 2018 +0200
+++ b/Framework/Toolbox/OrthancSlicesLoader.cpp	Tue Mar 27 11:12:50 2018 +0200
@@ -610,14 +610,17 @@
     // Decode a grayscale JPEG 8bpp image coming from the Web viewer
     std::auto_ptr<Orthanc::ImageAccessor> image
       (new Orthanc::Image(expectedFormat, reader->GetWidth(), reader->GetHeight(), false));
+     
+    Orthanc::ImageProcessing::Convert(*image, *reader);
+    reader.reset(NULL);
 
     float scaling = static_cast<float>(stretchHigh - stretchLow) / 255.0f;
-    float offset = static_cast<float>(stretchLow) / scaling;
-      
-    Orthanc::ImageProcessing::Convert(*image, *reader);
-    reader.reset(NULL);
-    
-    Orthanc::ImageProcessing::ShiftScale(*image, offset, scaling, true);
+
+    if (!LinearAlgebra::IsCloseToZero(scaling))
+    {
+      float offset = static_cast<float>(stretchLow) / scaling;
+      Orthanc::ImageProcessing::ShiftScale(*image, offset, scaling, true);
+    }
 
     NotifySliceImageSuccess(operation, image);
   }