changeset 3980:e42f5445d20d

Fix decoding of DICOM images for plugins
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 26 May 2020 09:04:00 +0200
parents 464d40d572bd
children 31252a887f0b
files NEWS OrthancServer/ServerContext.cpp OrthancServer/ServerContext.h Plugins/Engine/OrthancPlugins.cpp
diffstat 4 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Mon May 25 21:25:23 2020 +0200
+++ b/NEWS	Tue May 26 09:04:00 2020 +0200
@@ -2,6 +2,11 @@
 ===============================
 
 
+Maintenance
+-----------
+
+* Fix decoding of DICOM images for plugins
+
 
 Version 1.7.0 (2020-05-22)
 ==========================
--- a/OrthancServer/ServerContext.cpp	Mon May 25 21:25:23 2020 +0200
+++ b/OrthancServer/ServerContext.cpp	Tue May 26 09:04:00 2020 +0200
@@ -1296,6 +1296,16 @@
   }
 
 
+  ImageAccessor* ServerContext::DecodeDicomFrame(const void* dicom,
+                                                 size_t size,
+                                                 unsigned int frameIndex)
+  {
+    DicomInstanceToStore instance;
+    instance.SetBuffer(dicom, size);
+    return DecodeDicomFrame(instance, frameIndex);
+  }
+  
+
   void ServerContext::StoreWithTranscoding(std::string& sopClassUid,
                                            std::string& sopInstanceUid,
                                            DicomStoreUserConnection& connection,
--- a/OrthancServer/ServerContext.h	Mon May 25 21:25:23 2020 +0200
+++ b/OrthancServer/ServerContext.h	Tue May 26 09:04:00 2020 +0200
@@ -469,6 +469,10 @@
     ImageAccessor* DecodeDicomFrame(const DicomInstanceToStore& dicom,
                                     unsigned int frameIndex);
 
+    ImageAccessor* DecodeDicomFrame(const void* dicom,
+                                    size_t size,
+                                    unsigned int frameIndex);
+    
     void StoreWithTranscoding(std::string& sopClassUid,
                               std::string& sopInstanceUid,
                               DicomStoreUserConnection& connection,
--- a/Plugins/Engine/OrthancPlugins.cpp	Mon May 25 21:25:23 2020 +0200
+++ b/Plugins/Engine/OrthancPlugins.cpp	Tue May 26 09:04:00 2020 +0200
@@ -2922,7 +2922,8 @@
 
       case OrthancPluginImageFormat_Dicom:
       {
-        image.reset(Decode(p.data, p.size, 0));
+        PImpl::ServerContextLock lock(*pimpl_);
+        image.reset(lock.GetContext().DecodeDicomFrame(p.data, p.size, 0));
         break;
       }
 
@@ -3485,7 +3486,8 @@
 
       case _OrthancPluginService_DecodeDicomImage:
       {
-        result.reset(Decode(p.constBuffer, p.bufferSize, p.frameIndex));
+        PImpl::ServerContextLock lock(*pimpl_);
+        result.reset(lock.GetContext().DecodeDicomFrame(p.constBuffer, p.bufferSize, p.frameIndex));
         break;
       }