# HG changeset patch # User Sebastien Jodogne # Date 1780320637 -7200 # Node ID 7f1d9c7f33f0701dee9b8a3b191c0f050e2d6d87 # Parent 2b54c2e520a04bc02a7b1feca32580220efbeb30 using ServerContext::ReadTranscodedDicom() for modification of a single instance diff -r 2b54c2e520a0 -r 7f1d9c7f33f0 OrthancServer/Sources/OrthancRestApi/OrthancRestAnonymizeModify.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestAnonymizeModify.cpp Mon Jun 01 13:59:13 2026 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestAnonymizeModify.cpp Mon Jun 01 15:30:37 2026 +0200 @@ -25,7 +25,6 @@ #include "OrthancRestApi.h" #include "../../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" -#include "../../../OrthancFramework/Sources/DicomParsing/TranscodingCallable.h" #include "../../../OrthancFramework/Sources/Logging.h" #include "../../../OrthancFramework/Sources/SerializationToolbox.h" #include "../DicomInstanceToStore.h" @@ -218,30 +217,22 @@ std::unique_ptr modified; + if (transcode) + { + std::unique_ptr transcoded( + context.ReadTranscodedDicom(id, targetSyntax, TranscodingSopInstanceUidMode_AllowNew, true, lossyQuality)); + + TranscoderDataSource::Transcoded::LockAsParsed lock(*transcoded); + modified.reset(lock.GetContent().Clone(true)); + } + else { std::unique_ptr dicom(context.ReadParsedDicom(id)); modified.reset(dicom->Clone()); } modification.Apply(modified); - - if (transcode) - { - std::unique_ptr callable(new TranscodingCallable); - callable->AcquireParsed(*modified); // "modified" is invalid below this point - callable->AddTransferSyntax(targetSyntax); - callable->SetLossyQuality(lossyQuality); - - std::unique_ptr future(context.SubmitTranscodingRequest(callable.release())); - - std::unique_ptr transcoded(dynamic_cast(future->ReleaseResult())); - call.GetOutput().AnswerBuffer(transcoded->GetBufferData(), - transcoded->GetBufferSize(), MimeType_Dicom); - } - else - { - modified->Answer(call.GetOutput()); - } + modified->Answer(call.GetOutput()); }