# HG changeset patch # User Sebastien Jodogne # Date 1723824480 -7200 # Node ID 5f0529b2ce652ea03af395e1df9f9fd7a39123fa # Parent ff1aefb43763c08dc43a65c6a5a09b9b3864a41e fix default windowing for images without preset windowing diff -r ff1aefb43763 -r 5f0529b2ce65 Applications/StoneWebViewer/NEWS --- a/Applications/StoneWebViewer/NEWS Fri Aug 16 14:58:47 2024 +0200 +++ b/Applications/StoneWebViewer/NEWS Fri Aug 16 18:08:00 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 ff1aefb43763 -r 5f0529b2ce65 Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp --- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Fri Aug 16 14:58:47 2024 +0200 +++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Fri Aug 16 18:08:00 2024 +0200 @@ -1793,6 +1793,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(); } @@ -2086,6 +2102,8 @@ float windowingWidth_; std::vector windowingPresetCenters_; std::vector windowingPresetWidths_; + float windowingDefaultCenter_; + float windowingDefaultWidth_; unsigned int cineRate_; bool inverted_; bool fitNextContent_; @@ -2606,6 +2624,8 @@ context_(context), source_(source), framesCache_(cache), + windowingDefaultCenter_(128), + windowingDefaultWidth_(256), fitNextContent_(true), hasFocusOnInstance_(false), focusFrameNumber_(0), @@ -3158,7 +3178,7 @@ if (windowingPresetCenters_.empty()) { - SetWindowing(128, 256); + SetWindowing(windowingDefaultCenter_, windowingDefaultWidth_); } else {