changeset 2146:743fa9c74443 dicom-sr

integration mainline->dicom-sr
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 16 Aug 2024 18:09:53 +0200
parents 9d77c935f2c3 (current diff) 5f0529b2ce65 (diff)
children 82b8f1a3dafd
files Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp
diffstat 2 files changed, 22 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/StoneWebViewer/NEWS	Fri Aug 16 17:24:00 2024 +0200
+++ b/Applications/StoneWebViewer/NEWS	Fri Aug 16 18:09:53 2024 +0200
@@ -8,6 +8,7 @@
 
 * Prevent dragging series before they are ready
 * Open the first loaded series only if it is part of a selected study
+* Fix default windowing for images without preset windowing
 * Upgraded Emscripten version to 3.1.49
 
 
--- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Fri Aug 16 17:24:00 2024 +0200
+++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Fri Aug 16 18:09:53 2024 +0200
@@ -2207,6 +2207,22 @@
           LOG(INFO) << "No preset windowing";
         }
 
+        uint32_t bitsStored, pixelRepresentation;
+        if (dicom.ParseUnsignedInteger32(bitsStored, Orthanc::DICOM_TAG_BITS_STORED) &&
+            dicom.ParseUnsignedInteger32(pixelRepresentation, Orthanc::DICOM_TAG_PIXEL_REPRESENTATION))
+        {
+          // Added in Stone Web viewer > 2.5
+          const bool isSigned = (pixelRepresentation != 0);
+          const float maximum = powf(2.0, bitsStored);
+          GetViewport().windowingDefaultCenter_ = (isSigned ? 0.0f : maximum / 2.0f);
+          GetViewport().windowingDefaultWidth_ = maximum;
+        }
+        else
+        {
+          GetViewport().windowingDefaultCenter_ = 128;
+          GetViewport().windowingDefaultWidth_ = 256;
+        }
+
         GetViewport().SetWindowingPreset();
       }
 
@@ -2500,6 +2516,8 @@
   float                                        windowingWidth_;
   std::vector<float>                           windowingPresetCenters_;
   std::vector<float>                           windowingPresetWidths_;
+  float                                        windowingDefaultCenter_;
+  float                                        windowingDefaultWidth_;
   unsigned int                                 cineRate_;
   bool                                         inverted_;
   bool                                         fitNextContent_;
@@ -3049,6 +3067,8 @@
     context_(context),
     source_(source),
     framesCache_(cache),
+    windowingDefaultCenter_(128),
+    windowingDefaultWidth_(256),
     fitNextContent_(true),
     hasFocusOnInstance_(false),
     focusFrameNumber_(0),
@@ -3601,7 +3621,7 @@
 
     if (windowingPresetCenters_.empty())
     {
-      SetWindowing(128, 256);
+      SetWindowing(windowingDefaultCenter_, windowingDefaultWidth_);
     }
     else
     {