Mercurial > hg > orthanc
comparison OrthancServer/OrthancRestApi/OrthancRestResources.cpp @ 3686:a79aecf1f9ae
cont
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 24 Feb 2020 18:09:38 +0100 |
parents | 2cc34837d694 |
children | e6d6f8d23d02 |
comparison
equal
deleted
inserted
replaced
3685:2cc34837d694 | 3686:a79aecf1f9ae |
---|---|
667 }; | 667 }; |
668 | 668 |
669 | 669 |
670 class RenderedFrameHandler : public IDecodedFrameHandler | 670 class RenderedFrameHandler : public IDecodedFrameHandler |
671 { | 671 { |
672 private: | |
673 static void LookupWindowingTags(const DicomMap& dicom, | |
674 float& windowCenter, | |
675 float& windowWidth, | |
676 float& rescaleSlope, | |
677 float& rescaleIntercept, | |
678 bool& invert) | |
679 { | |
680 } | |
681 | |
682 public: | 672 public: |
683 virtual void Handle(RestApiGetCall& call, | 673 virtual void Handle(RestApiGetCall& call, |
684 std::auto_ptr<ImageAccessor>& decoded, | 674 std::auto_ptr<ImageAccessor>& decoded, |
685 const DicomMap& dicom) ORTHANC_OVERRIDE | 675 const DicomMap& dicom) ORTHANC_OVERRIDE |
686 { | 676 { |
807 throw OrthancException(ErrorCode_ParameterOutOfRange, | 797 throw OrthancException(ErrorCode_ParameterOutOfRange, |
808 "Argument must be Boolean: " + std::string(ARG_SMOOTH)); | 798 "Argument must be Boolean: " + std::string(ARG_SMOOTH)); |
809 } | 799 } |
810 } | 800 } |
811 | 801 |
802 | |
803 unsigned int width = decoded->GetWidth(); | |
804 unsigned int height = decoded->GetHeight(); | |
805 | |
806 if (decoded->GetWidth() != 0 && | |
807 decoded->GetHeight() != 0) | |
808 { | |
809 float ratio = 1; | |
810 | |
811 if (maxWidth != 0) | |
812 { | |
813 ratio = static_cast<float>(maxWidth) / static_cast<float>(decoded->GetWidth()); | |
814 } | |
815 | |
816 if (maxHeight != 0) | |
817 { | |
818 float ratioY = static_cast<float>(maxHeight) / static_cast<float>(decoded->GetHeight()); | |
819 if (ratioY < ratio) | |
820 { | |
821 ratio = ratioY; | |
822 } | |
823 } | |
824 | |
825 width = boost::math::iround(ratio * static_cast<float>(decoded->GetWidth())); | |
826 height = boost::math::iround(ratio * static_cast<float>(decoded->GetHeight())); | |
827 } | |
828 | |
812 if (decoded->GetFormat() == PixelFormat_RGB24) | 829 if (decoded->GetFormat() == PixelFormat_RGB24) |
813 { | 830 { |
814 if ((maxWidth == 0 && | 831 if (width == decoded->GetWidth() && |
815 maxHeight == 0) || | 832 height == decoded->GetHeight()) |
816 decoded->GetWidth() == 0 || | |
817 decoded->GetHeight() == 0) | |
818 { | 833 { |
819 DefaultHandler(call, decoded, ImageExtractionMode_Preview, false); | 834 DefaultHandler(call, decoded, ImageExtractionMode_Preview, false); |
820 } | 835 } |
821 else | 836 else |
822 { | 837 { |
823 float ratio = 1; | 838 std::auto_ptr<ImageAccessor> rescaled(new Image(decoded->GetFormat(), width, height, false)); |
824 | |
825 if (maxWidth != 0) | |
826 { | |
827 ratio = static_cast<float>(maxWidth) / static_cast<float>(decoded->GetWidth()); | |
828 } | |
829 | |
830 if (maxHeight != 0) | |
831 { | |
832 float ratioY = static_cast<float>(maxHeight) / static_cast<float>(decoded->GetHeight()); | |
833 if (ratioY < ratio) | |
834 { | |
835 ratio = ratioY; | |
836 } | |
837 } | |
838 | |
839 unsigned int width = boost::math::iround(ratio * static_cast<float>(decoded->GetWidth())); | |
840 unsigned int height = boost::math::iround(ratio * static_cast<float>(decoded->GetHeight())); | |
841 | |
842 std::auto_ptr<ImageAccessor> rescaled(new Image(PixelFormat_RGB24, width, height, false)); | |
843 if (smooth && | 839 if (smooth && |
844 ratio < 1) | 840 (width < decoded->GetWidth() || |
841 height < decoded->GetHeight())) | |
845 { | 842 { |
846 ImageProcessing::SmoothGaussian5x5(*decoded); | 843 ImageProcessing::SmoothGaussian5x5(*decoded); |
847 } | 844 } |
848 ImageProcessing::Resize(*rescaled, *decoded); | 845 ImageProcessing::Resize(*rescaled, *decoded); |
849 DefaultHandler(call, rescaled, ImageExtractionMode_Preview, false); | 846 DefaultHandler(call, rescaled, ImageExtractionMode_Preview, false); |
850 } | 847 } |
848 } | |
849 else | |
850 { | |
851 // TODO : (1) convert to float32, (2) apply windowing, (3) possibly rescale | |
852 throw OrthancException(ErrorCode_NotImplemented); | |
851 } | 853 } |
852 } | 854 } |
853 | 855 |
854 virtual bool RequiresDicomTags() const ORTHANC_OVERRIDE | 856 virtual bool RequiresDicomTags() const ORTHANC_OVERRIDE |
855 { | 857 { |