# HG changeset patch # User Sebastien Jodogne # Date 1597257013 -7200 # Node ID 5defca55680621f6c4591c26a308a00ca04173a0 # Parent a93c9fb871c4f72b0678849745e5941f1d01d9f3 Fix default windowing in rendered frames using WADO-URI and WADO-RS diff -r a93c9fb871c4 -r 5defca556806 NEWS --- a/NEWS Tue Aug 11 17:11:13 2020 +0200 +++ b/NEWS Wed Aug 12 20:30:13 2020 +0200 @@ -4,6 +4,7 @@ * Support transcoding in WADO-RS RetrieveStudy, RetrieveSeries and RetrieveInstance * Support of dynamic linking against the system-wide Orthanc framework library * Fix ".../rendered" on MONOCHROME1 images +* Fix default windowing in rendered frames using WADO-URI and WADO-RS Version 1.2 (2020-05-26) diff -r a93c9fb871c4 -r 5defca556806 Plugin/WadoRsRetrieveRendered.cpp --- a/Plugin/WadoRsRetrieveRendered.cpp Tue Aug 11 17:11:13 2020 +0200 +++ b/Plugin/WadoRsRetrieveRendered.cpp Wed Aug 12 20:30:13 2020 +0200 @@ -843,10 +843,19 @@ std::map headers; headers["Accept"] = Orthanc::EnumerationToString(mime); - // In DICOMweb, the "frame" parameter is in the range [1..N], - // whereas Orthanc uses range [0..N-1], hence the "-1" below. + /** + * (1) In DICOMweb, the "frame" parameter is in the range [1..N], + * whereas Orthanc uses range [0..N-1], hence the "-1" below. + * + * (2) We can use "/rendered" that was introduced in the REST API + * of Orthanc 1.6.0, as since release 1.2 of the DICOMweb plugin, + * the minimal SDK version is Orthanc 1.7.0 (in order to be able + * to use transcoding primitives). In releases <= 1.2, "/preview" + * was used, which caused one issue: + * https://groups.google.com/d/msg/orthanc-users/mKgr2QAKTCU/R7u4I1LvBAAJ + **/ if (buffer.RestApiGet("/instances/" + instanceId + "/frames/" + - boost::lexical_cast(frame - 1) + "/preview", headers, false)) + boost::lexical_cast(frame - 1) + "/rendered", headers, false)) { OrthancPluginAnswerBuffer(OrthancPlugins::GetGlobalContext(), output, buffer.GetData(), buffer.GetSize(), Orthanc::EnumerationToString(mime)); diff -r a93c9fb871c4 -r 5defca556806 Plugin/WadoUri.cpp --- a/Plugin/WadoUri.cpp Tue Aug 11 17:11:13 2020 +0200 +++ b/Plugin/WadoUri.cpp Wed Aug 12 20:30:13 2020 +0200 @@ -169,54 +169,50 @@ } -static bool RetrievePngPreview(OrthancPlugins::MemoryBuffer& png, - const std::string& instance) +static void AnswerPreview(OrthancPluginRestOutput* output, + const std::string& instance, + const std::map& httpHeaders) { - std::string uri = "/instances/" + instance + "/preview"; + /** + * (*) We can use "/rendered" that was introduced in the REST API of + * Orthanc 1.6.0, as since release 1.2 of the DICOMweb plugin, the + * minimal SDK version is Orthanc 1.7.0 (in order to be able to use + * transcoding primitives). In releases <= 1.2, "/preview" was used, + * which caused one issue: + * https://groups.google.com/d/msg/orthanc-users/mKgr2QAKTCU/R7u4I1LvBAAJ + **/ + const std::string uri = "/instances/" + instance + "/rendered"; - if (png.RestApiGet(uri, true)) + OrthancPluginContext* context = OrthancPlugins::GetGlobalContext(); + + OrthancPlugins::MemoryBuffer png; + if (png.RestApiGet(uri, httpHeaders, true)) { - return true; + OrthancPluginAnswerBuffer(context, output, png.GetData(), png.GetSize(), "image/png"); } else { OrthancPlugins::LogError("WADO-URI: Unable to generate a preview image for " + uri); - return false; + throw Orthanc::OrthancException(Orthanc::ErrorCode_Plugin); } } static void AnswerPngPreview(OrthancPluginRestOutput* output, - const std::string& instance) + const std::string& instance) { - OrthancPluginContext* context = OrthancPlugins::GetGlobalContext(); - - OrthancPlugins::MemoryBuffer png; - if (RetrievePngPreview(png, instance)) - { - OrthancPluginAnswerBuffer(context, output, - png.GetData(), png.GetSize(), "image/png"); - } - else - { - throw Orthanc::OrthancException(Orthanc::ErrorCode_Plugin); - } + std::map httpHeaders; + httpHeaders["Accept"] = "image/png"; + AnswerPreview(output, instance, httpHeaders); } static void AnswerJpegPreview(OrthancPluginRestOutput* output, const std::string& instance) { - // Retrieve the preview in the PNG format - OrthancPlugins::MemoryBuffer png; - if (!RetrievePngPreview(png, instance)) - { - throw Orthanc::OrthancException(Orthanc::ErrorCode_Plugin); - } - - OrthancPlugins::OrthancImage image; - image.UncompressPngImage(png.GetData(), png.GetSize()); - image.AnswerJpegImage(output, 90 /* quality */); + std::map httpHeaders; + httpHeaders["Accept"] = "image/jpeg"; + AnswerPreview(output, instance, httpHeaders); }