comparison 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
comparison
equal deleted inserted replaced
799:777b6b694da6 800:ecedd89055db
94 { 94 {
95 const std::string& name = members[i]; 95 const std::string& name = members[i];
96 std::string value = replacements[name].asString(); 96 std::string value = replacements[name].asString();
97 97
98 DicomTag tag = FromDcmtkBridge::ParseTag(name); 98 DicomTag tag = FromDcmtkBridge::ParseTag(name);
99 if (tag != DICOM_TAG_PIXEL_DATA) 99 target.Replace(tag, value);
100 {
101 target.Replace(tag, value);
102 }
103 100
104 VLOG(1) << "Replace: " << name << " " << tag << " == " << value << std::endl; 101 VLOG(1) << "Replace: " << name << " " << tag << " == " << value << std::endl;
105 } 102 }
106 } 103 }
107 104
404 401
405 402
406 static void Create(RestApi::PostCall& call) 403 static void Create(RestApi::PostCall& call)
407 { 404 {
408 // curl http://localhost:8042/tools/create-dicom -X POST -d '{"PatientName":"Hello^World"}' 405 // curl http://localhost:8042/tools/create-dicom -X POST -d '{"PatientName":"Hello^World"}'
406 // curl http://localhost:8042/tools/create-dicom -X POST -d '{"PatientName":"Hello^World","PixelData":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gUGDDcB53FulQAAAElJREFUGNNtj0sSAEEEQ1+U+185s1CtmRkblQ9CZldsKHJDk6DLGLJa6chjh0ooQmpjXMM86zPwydGEj6Ed/UGykkEM8X+p3u8/8LcOJIWLGeMAAAAASUVORK5CYII="}'
409 407
410 Json::Value request; 408 Json::Value request;
411 if (call.ParseJsonRequest(request) && request.isObject()) 409 if (call.ParseJsonRequest(request) && request.isObject())
412 { 410 {
413 DicomModification modification; 411 DicomModification modification;
414 ParseReplacements(modification, request); 412 ParseReplacements(modification, request);
415 413
416 ParsedDicomFile dicom; 414 ParsedDicomFile dicom;
415
416 if (modification.IsReplaced(DICOM_TAG_PIXEL_DATA))
417 {
418 dicom.EmbedImage(modification.GetReplacement(DICOM_TAG_PIXEL_DATA));
419 modification.Keep(DICOM_TAG_PIXEL_DATA);
420 }
421
417 modification.Apply(dicom); 422 modification.Apply(dicom);
418 423
419 std::string id; 424 std::string id;
420 StoreStatus status = OrthancRestApi::GetContext(call).Store(id, dicom); 425 StoreStatus status = OrthancRestApi::GetContext(call).Store(id, dicom);
421 426