# HG changeset patch # User Sebastien Jodogne # Date 1647785637 -3600 # Node ID 898774b4e02d32fc8baea0e33884cad9ecd873ef # Parent f81cdf283859d8f224065852969ffe001ef5f34a DicomInstanceParameters::CreateTexture() now sets pixel spacing diff -r f81cdf283859 -r 898774b4e02d Applications/Samples/Sdl/SingleFrameViewer/SdlSimpleViewerApplication.h --- a/Applications/Samples/Sdl/SingleFrameViewer/SdlSimpleViewerApplication.h Tue Feb 01 10:40:35 2022 +0100 +++ b/Applications/Samples/Sdl/SingleFrameViewer/SdlSimpleViewerApplication.h Sun Mar 20 15:13:57 2022 +0100 @@ -131,8 +131,6 @@ std::unique_ptr layer( message.GetInstanceParameters().CreateTexture(message.GetImage())); layer->SetLinearInterpolation(true); - layer->SetPixelSpacing(message.GetInstanceParameters().GetPixelSpacingX(), - message.GetInstanceParameters().GetPixelSpacingY()); { std::unique_ptr lock(viewport_->Lock()); diff -r f81cdf283859 -r 898774b4e02d OrthancStone/Sources/Toolbox/DicomInstanceParameters.cpp --- a/OrthancStone/Sources/Toolbox/DicomInstanceParameters.cpp Tue Feb 01 10:40:35 2022 +0100 +++ b/OrthancStone/Sources/Toolbox/DicomInstanceParameters.cpp Sun Mar 20 15:13:57 2022 +0100 @@ -596,16 +596,16 @@ throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); } + std::unique_ptr texture; + if (sourceFormat == Orthanc::PixelFormat_RGB24) { // This is the case of a color image. No conversion has to be done. - return new ColorTextureSceneLayer(pixelData); + texture.reset(new ColorTextureSceneLayer(pixelData)); } else { // This is the case of a grayscale frame. Convert it to Float32. - std::unique_ptr texture; - if (pixelData.GetFormat() == Orthanc::PixelFormat_Float32) { texture.reset(new FloatTextureSceneLayer(pixelData)); @@ -616,27 +616,34 @@ texture.reset(new FloatTextureSceneLayer(*converted)); } + FloatTextureSceneLayer& floatTexture = dynamic_cast(*texture); + if (GetWindowingPresetsCount() > 0) { - texture->SetCustomWindowing(GetWindowingPresetCenter(0), GetWindowingPresetWidth(0)); + floatTexture.SetCustomWindowing(GetWindowingPresetCenter(0), GetWindowingPresetWidth(0)); } switch (GetImageInformation().GetPhotometricInterpretation()) { case Orthanc::PhotometricInterpretation_Monochrome1: - texture->SetInverted(true); + floatTexture.SetInverted(true); break; case Orthanc::PhotometricInterpretation_Monochrome2: - texture->SetInverted(false); + floatTexture.SetInverted(false); break; default: break; } + } - return texture.release(); + if (HasPixelSpacing()) + { + texture->SetPixelSpacing(GetPixelSpacingX(), GetPixelSpacingY()); } + + return texture.release(); }