# HG changeset patch # User Sebastien Jodogne # Date 1540913696 -3600 # Node ID f559ac66ef5598021c1a3f0b23de1df055b4a1b5 # Parent 8262e4e9826de26b534f0596cd6593babb24f672 first export of a dicom image diff -r 8262e4e9826d -r f559ac66ef55 Applications/Samples/SingleFrameEditorApplication.h --- a/Applications/Samples/SingleFrameEditorApplication.h Tue Oct 30 10:47:13 2018 +0100 +++ b/Applications/Samples/SingleFrameEditorApplication.h Tue Oct 30 16:34:56 2018 +0100 @@ -31,12 +31,13 @@ #include #include #include +#include #include +#include +#include #include #include -#include - #include @@ -2603,8 +2604,13 @@ break; case 'e': - Export(GetStack(widget), 0.1, 0.1, GetWidget(widget).GetInterpolation()); + { + Orthanc::DicomMap tags; + tags.SetValue(Orthanc::DICOM_TAG_PATIENT_ID, "hello", false); + tags.SetValue(Orthanc::DICOM_TAG_PATIENT_NAME, "HELLO^WORLD", false); + Export(GetStack(widget), 0.1, 0.1, GetWidget(widget).GetInterpolation(), tags); break; + } case 'i': GetWidget(widget).SwitchInvert(); @@ -2678,7 +2684,8 @@ void Export(const BitmapStack& stack, double pixelSpacingX, double pixelSpacingY, - ImageInterpolation interpolation) + ImageInterpolation interpolation, + const Orthanc::DicomMap& dicom) { if (pixelSpacingX <= 0 || pixelSpacingY <= 0) @@ -2718,8 +2725,35 @@ layers.GetWidth(), layers.GetHeight(), false); Orthanc::ImageProcessing::Convert(rendered, layers); - Orthanc::PngWriter png; - png.WriteToFile("/tmp/a.png", rendered); + std::string pam; + { + Orthanc::PamWriter writer; + writer.WriteToMemory(pam, rendered); + } + + std::string content; + Orthanc::Toolbox::EncodeBase64(content, pam); + + std::set tags; + dicom.GetTags(tags); + + Json::Value json = Json::objectValue; + json["Tags"] = Json::objectValue; + + for (std::set::const_iterator + tag = tags.begin(); tag != tags.end(); ++tag) + { + const Orthanc::DicomValue& value = dicom.GetValue(*tag); + if (!value.IsNull() && + !value.IsBinary()) + { + json["Tags"][tag->Format()] = value.GetContent(); + } + } + + json["Content"] = "data:" + std::string(Orthanc::MIME_PAM) + ";base64," + content; + + orthanc_->PostJsonAsyncExpectJson("/tools/create-dicom", json, NULL, NULL, NULL); } }; @@ -2793,7 +2827,7 @@ fonts.AddFromResource(Orthanc::EmbeddedResources::FONT_UBUNTU_MONO_BOLD_16); stack_.reset(new BitmapStack(IObserver::broker_, *orthancApiClient_)); - stack_->LoadFrame(instance, frame, false).SetPan(200, 0); + stack_->LoadFrame(instance, frame, false); //.SetPan(200, 0); //stack_->LoadFrame("61f3143e-96f34791-ad6bbb8d-62559e75-45943e1b", 0, false); {