changeset 230:cce89307af28

replacing GdcmDecoder/OrthancImageWrapper.h by OrthancPluginCppWrapper.h
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 11 May 2020 12:06:33 +0200
parents 967ae255a58f
children 7097d0eaac76 b70d22f79320
files CMakeLists.txt Plugin/DecodedImageAdapter.cpp Plugin/DecodedImageAdapter.h Plugin/Plugin.cpp
diffstat 4 files changed, 18 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Mon May 11 11:52:46 2020 +0200
+++ b/CMakeLists.txt	Mon May 11 12:06:33 2020 +0200
@@ -143,6 +143,7 @@
   ${CORE_SOURCES}
   ${AUTOGENERATED_SOURCES}
   ${CMAKE_SOURCE_DIR}/Plugin/Plugin.cpp
+  ${ORTHANC_ROOT}/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp
 
   # The following files depend on GDCM
   ${CMAKE_SOURCE_DIR}/Plugin/DecodedImageAdapter.cpp
--- a/Plugin/DecodedImageAdapter.cpp	Mon May 11 11:52:46 2020 +0200
+++ b/Plugin/DecodedImageAdapter.cpp	Mon May 11 12:06:33 2020 +0200
@@ -27,7 +27,6 @@
 #include <Core/Images/ImageProcessing.h>
 #include <Core/OrthancException.h>
 #include <Core/Toolbox.h>
-#include <Plugins/Samples/GdcmDecoder/OrthancImageWrapper.h>
 
 #include <boost/lexical_cast.hpp>
 #include <boost/algorithm/string/predicate.hpp>
@@ -150,9 +149,9 @@
       throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource);
     }
 
-    std::unique_ptr<OrthancImageWrapper> image(
-      new OrthancImageWrapper(context_, OrthancPluginDecodeDicomImage(
-                                context_, dicom.c_str(), dicom.size(), frameIndex)));
+    std::unique_ptr<OrthancImage> image(
+      new OrthancImage(OrthancPluginDecodeDicomImage(
+                         context_, dicom.c_str(), dicom.size(), frameIndex)));
 
     Json::Value json;
     if (GetCornerstoneMetadata(json, tags, *image))
@@ -191,14 +190,14 @@
 
   bool DecodedImageAdapter::GetCornerstoneMetadata(Json::Value& result,
                                                    const Json::Value& tags,
-                                                   OrthancImageWrapper& image)
+                                                   OrthancImage& image)
   {
     using namespace Orthanc;
 
     float windowCenter, windowWidth;
 
     Orthanc::ImageAccessor accessor;
-    accessor.AssignReadOnly(OrthancPlugins::Convert(image.GetFormat()), image.GetWidth(),
+    accessor.AssignReadOnly(OrthancPlugins::Convert(image.GetPixelFormat()), image.GetWidth(),
                             image.GetHeight(), image.GetPitch(), image.GetBuffer());
 
     switch (accessor.GetFormat())
@@ -311,10 +310,10 @@
 
 
   bool  DecodedImageAdapter::EncodeUsingDeflate(Json::Value& result,
-                                                OrthancImageWrapper& image)
+                                                OrthancImage& image)
   {
     Orthanc::ImageAccessor accessor;
-    accessor.AssignReadOnly(OrthancPlugins::Convert(image.GetFormat()), image.GetWidth(),
+    accessor.AssignReadOnly(OrthancPlugins::Convert(image.GetPixelFormat()), image.GetWidth(),
                             image.GetHeight(), image.GetPitch(), image.GetBuffer());
 
     std::unique_ptr<Orthanc::ImageBuffer> buffer;
@@ -363,7 +362,7 @@
     result["sizeInBytes"] = converted.GetSize();
 
     std::string z;
-    CompressUsingDeflate(z, image.GetContext(), converted.GetConstBuffer(), converted.GetSize());
+    CompressUsingDeflate(z, GetGlobalContext(), converted.GetConstBuffer(), converted.GetSize());
     
     std::string s;
     Orthanc::Toolbox::EncodeBase64(s, z);
@@ -422,11 +421,11 @@
 
 
   bool  DecodedImageAdapter::EncodeUsingJpeg(Json::Value& result,
-                                             OrthancImageWrapper& image,
+                                             OrthancImage& image,
                                              uint8_t quality /* between 0 and 100 */)
   {
     Orthanc::ImageAccessor accessor;
-    accessor.AssignReadOnly(OrthancPlugins::Convert(image.GetFormat()), image.GetWidth(),
+    accessor.AssignReadOnly(OrthancPlugins::Convert(image.GetPixelFormat()), image.GetWidth(),
                             image.GetHeight(), image.GetPitch(), image.GetBuffer());
 
     std::unique_ptr<Orthanc::ImageBuffer> buffer;
@@ -485,7 +484,7 @@
     result["sizeInBytes"] = converted.GetSize();
 
     std::string jpeg;
-    WriteJpegToMemory(jpeg, image.GetContext(), converted, quality);
+    WriteJpegToMemory(jpeg, GetGlobalContext(), converted, quality);
 
     std::string s;
     Orthanc::Toolbox::EncodeBase64(s, jpeg);
--- a/Plugin/DecodedImageAdapter.h	Mon May 11 11:52:46 2020 +0200
+++ b/Plugin/DecodedImageAdapter.h	Mon May 11 12:06:33 2020 +0200
@@ -27,7 +27,7 @@
 #include <stdint.h>
 #include <json/value.h>
 
-#include <Plugins/Samples/GdcmDecoder/OrthancImageWrapper.h>
+#include <Plugins/Samples/Common/OrthancPluginCppWrapper.h>
 
 
 namespace OrthancPlugins
@@ -49,13 +49,13 @@
 
     static bool GetCornerstoneMetadata(Json::Value& result,
                                        const Json::Value& tags,
-                                       OrthancImageWrapper& image);
+                                       OrthancImage& image);
 
     static bool EncodeUsingDeflate(Json::Value& result,
-                                   OrthancImageWrapper& image);
+                                   OrthancImage& image);
 
     static bool EncodeUsingJpeg(Json::Value& result,
-                                OrthancImageWrapper& image,
+                                OrthancImage& image,
                                 uint8_t quality /* between 0 and 100 */);
 
     OrthancPluginContext* context_;
--- a/Plugin/Plugin.cpp	Mon May 11 11:52:46 2020 +0200
+++ b/Plugin/Plugin.cpp	Mon May 11 12:06:33 2020 +0200
@@ -28,6 +28,7 @@
 #include <Core/OrthancException.h>
 #include <Core/SystemToolbox.h>
 #include <Core/Toolbox.h>
+#include <Plugins/Samples/Common/OrthancPluginCppWrapper.h>
 #include <Plugins/Samples/GdcmDecoder/GdcmDecoderCache.h>
 
 #include <boost/thread.hpp>
@@ -568,6 +569,7 @@
   {
     using namespace OrthancPlugins;
 
+    OrthancPlugins::SetGlobalContext(context);
     context_ = context;
     assert(DisplayPerformanceWarning());
     OrthancPluginLogWarning(context_, "Initializing the Web viewer");