# HG changeset patch # User Sebastien Jodogne # Date 1729604498 -7200 # Node ID 239fb2c893c183da0e15dcb8a32d4d4270c57e75 # Parent 8e3c403cc6430c5969b288fd57d5a6f6aa6fdcd7 automatically stretch to whole range for images without preset diff -r 8e3c403cc643 -r 239fb2c893c1 Applications/StoneWebViewer/NEWS --- a/Applications/StoneWebViewer/NEWS Tue Oct 22 15:40:40 2024 +0200 +++ b/Applications/StoneWebViewer/NEWS Tue Oct 22 15:41:38 2024 +0200 @@ -1,6 +1,7 @@ Pending changes in the mainline =============================== +* Automatically stretch to whole range for images without preset * Improved support of the (0028,9132) tag for Philips multiframe images * Remember the previous layout when re-opening the viewer. * Added a Print button in the PDF viewer toolbar. diff -r 8e3c403cc643 -r 239fb2c893c1 Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp --- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Tue Oct 22 15:40:40 2024 +0200 +++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Tue Oct 22 15:41:38 2024 +0200 @@ -2405,6 +2405,25 @@ std::unique_ptr tmp( new OrthancStone::FloatTextureSceneLayer(frame)); + if (windowingTracker_.GetState() == WindowingState_None || + windowingTracker_.GetState() == WindowingState_Fallback) + { + const Orthanc::ImageAccessor& texture = tmp->GetTexture(); + if (texture.GetFormat() != Orthanc::PixelFormat_Float32) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + } + else + { + float minValue, maxValue; + Orthanc::ImageProcessing::GetMinMaxFloatValue(minValue, maxValue, texture); + + const float center = (minValue + maxValue) / 2.0f; + const float width = maxValue - minValue; + UpdateWindowing(WindowingState_Fallback, OrthancStone::Windowing(center, width)); + } + } + tmp->SetCustomWindowing(windowingTracker_.GetWindowing().GetCenter(), windowingTracker_.GetWindowing().GetWidth()); tmp->SetInverted(inverted_ ^ isMonochrome1); layer.reset(tmp.release());