Mercurial > hg > orthanc-stone
changeset 2172:239fb2c893c1
automatically stretch to whole range for images without preset
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 22 Oct 2024 15:41:38 +0200 |
parents | 8e3c403cc643 |
children | 4596ad1b2aa4 2410a171ebfb |
files | Applications/StoneWebViewer/NEWS Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp |
diffstat | 2 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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.
--- 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<OrthancStone::FloatTextureSceneLayer> 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());