# HG changeset patch # User Sebastien Jodogne # Date 1522141970 -7200 # Node ID 431e991af593002e9d7c0c50e43626daeee84784 # Parent e7f90aba3c97a3f8fad0f1d74fcce22a0a3a2d4c fix diff -r e7f90aba3c97 -r 431e991af593 Framework/Toolbox/OrthancSlicesLoader.cpp --- 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 image (new Orthanc::Image(expectedFormat, reader->GetWidth(), reader->GetHeight(), false)); + + Orthanc::ImageProcessing::Convert(*image, *reader); + reader.reset(NULL); float scaling = static_cast(stretchHigh - stretchLow) / 255.0f; - float offset = static_cast(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(stretchLow) / scaling; + Orthanc::ImageProcessing::ShiftScale(*image, offset, scaling, true); + } NotifySliceImageSuccess(operation, image); }