changeset 2848:dd3914a44b87

added accessors in C++ wrappers
author am@osimis.io
date Mon, 01 Oct 2018 11:35:01 +0200
parents 2da68edacab6
children c67b5d80b758 9f949922d603
files Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Plugins/Samples/Common/OrthancPluginCppWrapper.h
diffstat 2 files changed, 46 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Fri Sep 28 19:17:04 2018 +0200
+++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp	Mon Oct 01 11:35:01 2018 +0200
@@ -231,6 +231,18 @@
     Check(OrthancPluginCreateDicom(context_, &buffer_, s.c_str(), NULL, flags));
   }
 
+  void MemoreyBuffer::CreateDicom(const Json::Value& tags,
+                   const OrthancPluginImage& pixelData,
+                   OrthancPluginCreateDicomFlags flags)
+  {
+    Clear();
+
+    Json::FastWriter writer;
+    std::string s = writer.write(tags);
+
+    Check(OrthancPluginCreateDicom(context_, &buffer_, s.c_str(), pixelData.GetObject(), flags));
+  }
+
 
   void MemoryBuffer::ReadFile(const std::string& path)
   {
@@ -885,6 +897,23 @@
     }
   }
 
+  OrthancImage::OrthancImage(OrthancPluginContext*     context,
+                             OrthancPluginPixelFormat  format,
+                             uint32_t                  width,
+                             uint32_t                  height,
+                             uint32_t                  pitch,
+                             void*                     buffer) :
+    context_(context)
+  {
+    if (context == NULL)
+    {
+      ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange);
+    }
+    else
+    {
+      image_ = OrthancPluginCreateImageAccessor(context, format, width, height, pitch, buffer);
+    }
+  }
 
   void OrthancImage::UncompressPngImage(const void* data,
                                         size_t size)
--- a/Plugins/Samples/Common/OrthancPluginCppWrapper.h	Fri Sep 28 19:17:04 2018 +0200
+++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.h	Mon Oct 01 11:35:01 2018 +0200
@@ -79,6 +79,9 @@
                                 const char* url,
                                 const OrthancPluginHttpRequest* request);
 
+  class OrthancPluginImage;
+
+
   class MemoryBuffer : public boost::noncopyable
   {
   private:
@@ -168,6 +171,10 @@
     void CreateDicom(const Json::Value& tags,
                      OrthancPluginCreateDicomFlags flags);
 
+    void CreateDicom(const Json::Value& tags,
+                     const OrthancImage& pixelData,
+                     OrthancPluginCreateDicomFlags flags);
+
     void ReadFile(const std::string& path);
 
     void GetDicomQuery(const OrthancPluginWorklistQuery* query);
@@ -321,6 +328,14 @@
                  uint32_t                  width,
                  uint32_t                  height);
 
+    OrthancImage(OrthancPluginContext*     context,
+                 OrthancPluginPixelFormat  format,
+                 uint32_t                  width,
+                 uint32_t                  height,
+                 uint32_t                  pitch,
+                 void*                     buffer
+                 );
+
     ~OrthancImage()
     {
       Clear();
@@ -346,6 +361,8 @@
     
     const void* GetBuffer();
 
+    const OrthancPluginImage* GetObject() const {return image_;}
+
     void CompressPngImage(MemoryBuffer& target);
 
     void CompressJpegImage(MemoryBuffer& target,