diff OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp @ 800:ecedd89055db

generation of DICOM images from PNG files
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 06 May 2014 16:33:40 +0200
parents e7b1ca0f1e04
children a811bdf8b8eb
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp	Tue May 06 12:55:41 2014 +0200
+++ b/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp	Tue May 06 16:33:40 2014 +0200
@@ -96,10 +96,7 @@
       std::string value = replacements[name].asString();
 
       DicomTag tag = FromDcmtkBridge::ParseTag(name);
-      if (tag != DICOM_TAG_PIXEL_DATA)
-      {
-        target.Replace(tag, value);
-      }
+      target.Replace(tag, value);
 
       VLOG(1) << "Replace: " << name << " " << tag << " == " << value << std::endl;
     }
@@ -406,6 +403,7 @@
   static void Create(RestApi::PostCall& call)
   {
     // curl http://localhost:8042/tools/create-dicom -X POST -d '{"PatientName":"Hello^World"}'
+    // curl http://localhost:8042/tools/create-dicom -X POST -d '{"PatientName":"Hello^World","PixelData":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gUGDDcB53FulQAAAElJREFUGNNtj0sSAEEEQ1+U+185s1CtmRkblQ9CZldsKHJDk6DLGLJa6chjh0ooQmpjXMM86zPwydGEj6Ed/UGykkEM8X+p3u8/8LcOJIWLGeMAAAAASUVORK5CYII="}'
 
     Json::Value request;
     if (call.ParseJsonRequest(request) && request.isObject())
@@ -414,6 +412,13 @@
       ParseReplacements(modification, request);
 
       ParsedDicomFile dicom;
+
+      if (modification.IsReplaced(DICOM_TAG_PIXEL_DATA))
+      {
+        dicom.EmbedImage(modification.GetReplacement(DICOM_TAG_PIXEL_DATA));
+        modification.Keep(DICOM_TAG_PIXEL_DATA);
+      }
+
       modification.Apply(dicom);
 
       std::string id;