changeset 127:5754d39b011d

Option "EnableGdcm" to replace the built-in decoder of Orthanc with GDCM
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 25 Mar 2016 17:38:34 +0100
parents f99adade8b77
children e8cfda4c8a2f
files NEWS Plugin/Plugin.cpp
diffstat 2 files changed, 23 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Fri Mar 25 11:55:35 2016 +0100
+++ b/NEWS	Fri Mar 25 17:38:34 2016 +0100
@@ -1,6 +1,7 @@
 Pending changes in the mainline
 ===============================
 
+* Option "EnableGdcm" to replace the built-in decoder of Orthanc with GDCM
 * Fixed rendering of 16bpp images if values are < 0 or >= 32768
 
 
--- a/Plugin/Plugin.cpp	Fri Mar 25 11:55:35 2016 +0100
+++ b/Plugin/Plugin.cpp	Fri Mar 25 17:38:34 2016 +0100
@@ -390,10 +390,6 @@
     OrthancPluginSetDescription(context_, "Provides a Web viewer of DICOM series within Orthanc.");
 
 
-    // Replace the default decoder of DICOM images that is built in Orthanc
-    OrthancPluginRegisterDecodeImageCallback(context_, DecodeImageCallback);
-
-
     /* By default, use half of the available processing cores for the decoding of DICOM images */
     int decodingThreads = boost::thread::hardware_concurrency() / 2;
     if (decodingThreads == 0)
@@ -401,6 +397,9 @@
       decodingThreads = 1;
     }
 
+    /* By default, use GDCM */
+    bool enableGdcm = true;
+
 
     try
     {
@@ -430,6 +429,12 @@
         cachePath = GetStringValue(configuration["WebViewer"], key, cachePath.string());
         cacheSize = GetIntegerValue(configuration["WebViewer"], "CacheSize", cacheSize);
         decodingThreads = GetIntegerValue(configuration["WebViewer"], "Threads", decodingThreads);
+
+        if (configuration["WebViewer"].isMember("EnableGdcm") &&
+            configuration["WebViewer"]["EnableGdcm"].type() == Json::booleanValue)
+        {
+          enableGdcm = configuration["WebViewer"]["EnableGdcm"].asBool();
+        }
       }
 
       std::string message = ("Web viewer using " + boost::lexical_cast<std::string>(decodingThreads) + 
@@ -515,6 +520,19 @@
     }
 
 
+    /* Configure the DICOM decoder */
+    if (enableGdcm)
+    {
+      // Replace the default decoder of DICOM images that is built in Orthanc
+      OrthancPluginLogWarning(context_, "Using GDCM instead of the DICOM decoder that is built in Orthanc");
+      OrthancPluginRegisterDecodeImageCallback(context_, DecodeImageCallback);
+    }
+    else
+    {
+      OrthancPluginLogWarning(context_, "Using the DICOM decoder that is built in Orthanc (not using GDCM)");
+    }
+
+
     /* Install the callbacks */
     OrthancPluginRegisterRestCallback(context_, "/web-viewer/series/(.*)", ServeCache<CacheBundle_SeriesInformation>);
     OrthancPluginRegisterRestCallback(context_, "/web-viewer/is-stable-series/(.*)", IsStableSeries);