diff Plugin/DecodedImageAdapter.cpp @ 31:111689a2c177

author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 24 Jun 2015 16:20:41 +0200
parents 02f7a0400a91
children a6ba21a083e5
line wrap: on
line diff
--- a/Plugin/DecodedImageAdapter.cpp	Thu Jun 04 10:18:43 2015 +0200
+++ b/Plugin/DecodedImageAdapter.cpp	Wed Jun 24 16:20:41 2015 +0200
@@ -84,39 +84,32 @@
       return false;
     }
 
-    std::string file = "/instances/" + instanceId + "/file";
-
-    std::string dicom;
-    if (!GetStringFromOrthanc(dicom, context_, file))
-    {
-      return false;
-    }
-
-    ParsedDicomImage image(dicom);
+    ParsedDicomImage image(context_, instanceId);
 
     Json::Value json;
+    bool ok = false;
 
     if (type == CompressionType_Deflate)
     {
-      if (!image.EncodeUsingDeflate(json, 9))
-      {
-        return false;
-      }
+      ok = image.EncodeUsingDeflate(json, 9);
     }
     else if (type == CompressionType_Jpeg)
     {
-      if (!image.EncodeUsingJpeg(json, level))
-      {
-        return false;
-      }
+      ok = image.EncodeUsingJpeg(json, level);
+    }
+
+    if (ok)
+    {
+      Json::FastWriter writer;
+      content = writer.write(json);
+      return true;
     }
     else
     {
+      char msg[1024];
+      sprintf(msg, "Unable to decode the following instance: %s", uri.c_str());
+      OrthancPluginLogWarning(context_, msg);
       return false;
     }
-
-    Json::FastWriter writer;
-    content = writer.write(json);
-    return true;
   }
 }