comparison OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp @ 1562:2084b7c20478

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 21 Aug 2015 13:47:22 +0200
parents 124de28b32ed
children 1b7def486e62
comparison
equal deleted inserted replaced
1560:307b9ea6c39b 1562:2084b7c20478
451 std::string value = request[name].asString(); 451 std::string value = request[name].asString();
452 452
453 DicomTag tag = FromDcmtkBridge::ParseTag(name); 453 DicomTag tag = FromDcmtkBridge::ParseTag(name);
454 if (tag == DICOM_TAG_PIXEL_DATA) 454 if (tag == DICOM_TAG_PIXEL_DATA)
455 { 455 {
456 dicom.EmbedImage(value); 456 dicom.EmbedContent(value);
457 } 457 }
458 else 458 else
459 { 459 {
460 dicom.Replace(tag, value); 460 dicom.Replace(tag, value);
461 } 461 }
645 { 645 {
646 LOG(ERROR) << "The payload of the DICOM instance must be specified according to Data URI scheme"; 646 LOG(ERROR) << "The payload of the DICOM instance must be specified according to Data URI scheme";
647 return false; 647 return false;
648 } 648 }
649 649
650 std::string mime, base64; 650 dicom.EmbedContent(request["Content"].asString());
651 Toolbox::DecodeDataUriScheme(mime, base64, request["Content"].asString());
652 Toolbox::ToLowerCase(mime);
653
654 std::string content;
655 Toolbox::DecodeBase64(content, base64);
656
657 if (mime == "image/png")
658 {
659 dicom.EmbedImage(mime, content);
660 }
661 else if (mime == "application/pdf")
662 {
663 dicom.EmbedPdf(content);
664 }
665 else
666 {
667 LOG(ERROR) << "Unsupported MIME type for the content of a new DICOM file";
668 return false;
669 }
670 } 651 }
671 652
672 653
673 return true; 654 return true;
674 } 655 }