Mercurial > hg > orthanc-stone
diff OrthancStone/Sources/Toolbox/DicomInstanceParameters.cpp @ 1911:898774b4e02d
DicomInstanceParameters::CreateTexture() now sets pixel spacing
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sun, 20 Mar 2022 15:13:57 +0100 |
parents | 7053b8a0aaec |
children | ed4831e08961 |
line wrap: on
line diff
--- 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<TextureBaseSceneLayer> 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<FloatTextureSceneLayer> 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<FloatTextureSceneLayer&>(*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(); }