Mercurial > hg > orthanc-stone
comparison 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 |
comparison
equal
deleted
inserted
replaced
1910:f81cdf283859 | 1911:898774b4e02d |
---|---|
594 if (sourceFormat != GetExpectedPixelFormat()) | 594 if (sourceFormat != GetExpectedPixelFormat()) |
595 { | 595 { |
596 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); | 596 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); |
597 } | 597 } |
598 | 598 |
599 std::unique_ptr<TextureBaseSceneLayer> texture; | |
600 | |
599 if (sourceFormat == Orthanc::PixelFormat_RGB24) | 601 if (sourceFormat == Orthanc::PixelFormat_RGB24) |
600 { | 602 { |
601 // This is the case of a color image. No conversion has to be done. | 603 // This is the case of a color image. No conversion has to be done. |
602 return new ColorTextureSceneLayer(pixelData); | 604 texture.reset(new ColorTextureSceneLayer(pixelData)); |
603 } | 605 } |
604 else | 606 else |
605 { | 607 { |
606 // This is the case of a grayscale frame. Convert it to Float32. | 608 // This is the case of a grayscale frame. Convert it to Float32. |
607 std::unique_ptr<FloatTextureSceneLayer> texture; | |
608 | |
609 if (pixelData.GetFormat() == Orthanc::PixelFormat_Float32) | 609 if (pixelData.GetFormat() == Orthanc::PixelFormat_Float32) |
610 { | 610 { |
611 texture.reset(new FloatTextureSceneLayer(pixelData)); | 611 texture.reset(new FloatTextureSceneLayer(pixelData)); |
612 } | 612 } |
613 else | 613 else |
614 { | 614 { |
615 std::unique_ptr<Orthanc::ImageAccessor> converted(ConvertToFloat(pixelData)); | 615 std::unique_ptr<Orthanc::ImageAccessor> converted(ConvertToFloat(pixelData)); |
616 texture.reset(new FloatTextureSceneLayer(*converted)); | 616 texture.reset(new FloatTextureSceneLayer(*converted)); |
617 } | 617 } |
618 | 618 |
619 FloatTextureSceneLayer& floatTexture = dynamic_cast<FloatTextureSceneLayer&>(*texture); | |
620 | |
619 if (GetWindowingPresetsCount() > 0) | 621 if (GetWindowingPresetsCount() > 0) |
620 { | 622 { |
621 texture->SetCustomWindowing(GetWindowingPresetCenter(0), GetWindowingPresetWidth(0)); | 623 floatTexture.SetCustomWindowing(GetWindowingPresetCenter(0), GetWindowingPresetWidth(0)); |
622 } | 624 } |
623 | 625 |
624 switch (GetImageInformation().GetPhotometricInterpretation()) | 626 switch (GetImageInformation().GetPhotometricInterpretation()) |
625 { | 627 { |
626 case Orthanc::PhotometricInterpretation_Monochrome1: | 628 case Orthanc::PhotometricInterpretation_Monochrome1: |
627 texture->SetInverted(true); | 629 floatTexture.SetInverted(true); |
628 break; | 630 break; |
629 | 631 |
630 case Orthanc::PhotometricInterpretation_Monochrome2: | 632 case Orthanc::PhotometricInterpretation_Monochrome2: |
631 texture->SetInverted(false); | 633 floatTexture.SetInverted(false); |
632 break; | 634 break; |
633 | 635 |
634 default: | 636 default: |
635 break; | 637 break; |
636 } | 638 } |
637 | 639 } |
638 return texture.release(); | 640 |
639 } | 641 if (HasPixelSpacing()) |
642 { | |
643 texture->SetPixelSpacing(GetPixelSpacingX(), GetPixelSpacingY()); | |
644 } | |
645 | |
646 return texture.release(); | |
640 } | 647 } |
641 | 648 |
642 | 649 |
643 LookupTableTextureSceneLayer* DicomInstanceParameters::CreateLookupTableTexture | 650 LookupTableTextureSceneLayer* DicomInstanceParameters::CreateLookupTableTexture |
644 (const Orthanc::ImageAccessor& pixelData) const | 651 (const Orthanc::ImageAccessor& pixelData) const |