# HG changeset patch # User Sebastien Jodogne # Date 1723824593 -7200 # Node ID 743fa9c74443cacbee2e42d698c0ba072faefad3 # Parent 9d77c935f2c38d93c1a5df4e9617439a11f0367b# Parent 5f0529b2ce652ea03af395e1df9f9fd7a39123fa integration mainline->dicom-sr diff -r 9d77c935f2c3 -r 743fa9c74443 Applications/StoneWebViewer/NEWS --- 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 diff -r 9d77c935f2c3 -r 743fa9c74443 Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp --- 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 windowingPresetCenters_; std::vector 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 {