comparison Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp @ 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
comparison
equal deleted inserted replaced
2171:8e3c403cc643 2172:239fb2c893c1
2403 } 2403 }
2404 2404
2405 std::unique_ptr<OrthancStone::FloatTextureSceneLayer> tmp( 2405 std::unique_ptr<OrthancStone::FloatTextureSceneLayer> tmp(
2406 new OrthancStone::FloatTextureSceneLayer(frame)); 2406 new OrthancStone::FloatTextureSceneLayer(frame));
2407 2407
2408 if (windowingTracker_.GetState() == WindowingState_None ||
2409 windowingTracker_.GetState() == WindowingState_Fallback)
2410 {
2411 const Orthanc::ImageAccessor& texture = tmp->GetTexture();
2412 if (texture.GetFormat() != Orthanc::PixelFormat_Float32)
2413 {
2414 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
2415 }
2416 else
2417 {
2418 float minValue, maxValue;
2419 Orthanc::ImageProcessing::GetMinMaxFloatValue(minValue, maxValue, texture);
2420
2421 const float center = (minValue + maxValue) / 2.0f;
2422 const float width = maxValue - minValue;
2423 UpdateWindowing(WindowingState_Fallback, OrthancStone::Windowing(center, width));
2424 }
2425 }
2426
2408 tmp->SetCustomWindowing(windowingTracker_.GetWindowing().GetCenter(), windowingTracker_.GetWindowing().GetWidth()); 2427 tmp->SetCustomWindowing(windowingTracker_.GetWindowing().GetCenter(), windowingTracker_.GetWindowing().GetWidth());
2409 tmp->SetInverted(inverted_ ^ isMonochrome1); 2428 tmp->SetInverted(inverted_ ^ isMonochrome1);
2410 layer.reset(tmp.release()); 2429 layer.reset(tmp.release());
2411 break; 2430 break;
2412 } 2431 }