# HG changeset patch # User Sebastien Jodogne # Date 1582564178 -3600 # Node ID a79aecf1f9ae2cf7abb5e24f5a375179de52d5e3 # Parent 2cc34837d69494556870b92030ddcf28ca5615d0 cont diff -r 2cc34837d694 -r a79aecf1f9ae OrthancServer/OrthancRestApi/OrthancRestResources.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Mon Feb 24 17:58:59 2020 +0100 +++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Mon Feb 24 18:09:38 2020 +0100 @@ -669,16 +669,6 @@ class RenderedFrameHandler : public IDecodedFrameHandler { - private: - static void LookupWindowingTags(const DicomMap& dicom, - float& windowCenter, - float& windowWidth, - float& rescaleSlope, - float& rescaleIntercept, - bool& invert) - { - } - public: virtual void Handle(RestApiGetCall& call, std::auto_ptr& decoded, @@ -809,39 +799,46 @@ } } + + unsigned int width = decoded->GetWidth(); + unsigned int height = decoded->GetHeight(); + + if (decoded->GetWidth() != 0 && + decoded->GetHeight() != 0) + { + float ratio = 1; + + if (maxWidth != 0) + { + ratio = static_cast(maxWidth) / static_cast(decoded->GetWidth()); + } + + if (maxHeight != 0) + { + float ratioY = static_cast(maxHeight) / static_cast(decoded->GetHeight()); + if (ratioY < ratio) + { + ratio = ratioY; + } + } + + width = boost::math::iround(ratio * static_cast(decoded->GetWidth())); + height = boost::math::iround(ratio * static_cast(decoded->GetHeight())); + } + if (decoded->GetFormat() == PixelFormat_RGB24) { - if ((maxWidth == 0 && - maxHeight == 0) || - decoded->GetWidth() == 0 || - decoded->GetHeight() == 0) + if (width == decoded->GetWidth() && + height == decoded->GetHeight()) { DefaultHandler(call, decoded, ImageExtractionMode_Preview, false); } else { - float ratio = 1; - - if (maxWidth != 0) - { - ratio = static_cast(maxWidth) / static_cast(decoded->GetWidth()); - } - - if (maxHeight != 0) - { - float ratioY = static_cast(maxHeight) / static_cast(decoded->GetHeight()); - if (ratioY < ratio) - { - ratio = ratioY; - } - } - - unsigned int width = boost::math::iround(ratio * static_cast(decoded->GetWidth())); - unsigned int height = boost::math::iround(ratio * static_cast(decoded->GetHeight())); - - std::auto_ptr rescaled(new Image(PixelFormat_RGB24, width, height, false)); + std::auto_ptr rescaled(new Image(decoded->GetFormat(), width, height, false)); if (smooth && - ratio < 1) + (width < decoded->GetWidth() || + height < decoded->GetHeight())) { ImageProcessing::SmoothGaussian5x5(*decoded); } @@ -849,6 +846,11 @@ DefaultHandler(call, rescaled, ImageExtractionMode_Preview, false); } } + else + { + // TODO : (1) convert to float32, (2) apply windowing, (3) possibly rescale + throw OrthancException(ErrorCode_NotImplemented); + } } virtual bool RequiresDicomTags() const ORTHANC_OVERRIDE