# HG changeset patch # User Sebastien Jodogne # Date 1642008365 -3600 # Node ID fba6e550e0ee76133920165b71c00bef84f7988c # Parent 4e80b8afd0dae5241bbe15e373e380b1cab2f12b apply rescale slope/intercept in rendering plugin diff -r 4e80b8afd0da -r fba6e550e0ee RenderingPlugin/Sources/Plugin.cpp --- a/RenderingPlugin/Sources/Plugin.cpp Wed Jan 12 18:02:24 2022 +0100 +++ b/RenderingPlugin/Sources/Plugin.cpp Wed Jan 12 18:26:05 2022 +0100 @@ -23,6 +23,7 @@ #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" #include "../../OrthancStone/Sources/Toolbox/AffineTransform2D.h" +#include "../../OrthancStone/Sources/Toolbox/DicomInstanceParameters.h" #include @@ -61,7 +62,20 @@ const OrthancPluginHttpRequest* request) { // TODO: Parameters in GET - // TODO: Rescale slope/intercept + + OrthancPlugins::MemoryBuffer tags; + if (!tags.RestApiGet("/instances/" + std::string(request->groups[0]) + "/tags", false)) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentItem); + } + + Json::Value json; + tags.ToJson(json); + + Orthanc::DicomMap m; + m.FromDicomAsJson(json); + + OrthancStone::DicomInstanceParameters parameters(m); OrthancPlugins::MemoryBuffer dicom; dicom.GetDicomInstance(request->groups[0]); @@ -103,11 +117,11 @@ } else { - Orthanc::Image converted(Orthanc::PixelFormat_Float32, image.GetWidth(), image.GetHeight(), false); - Orthanc::ImageProcessing::Convert(converted, source); + std::unique_ptr converted(parameters.ConvertToFloat(source)); - modified.reset(new Orthanc::Image(converted.GetFormat(), converted.GetWidth(), converted.GetHeight(), false)); - t.Apply(*modified, converted, OrthancStone::ImageInterpolation_Bilinear, true); + assert(converted.get() != NULL); + modified.reset(new Orthanc::Image(converted->GetFormat(), converted->GetWidth(), converted->GetHeight(), false)); + t.Apply(*modified, *converted, OrthancStone::ImageInterpolation_Bilinear, true); } assert(modified.get() != NULL);