comparison Core/DicomParsing/MemoryBufferTranscoder.cpp @ 3944:aae045f802f4 transcoding

preparing simplified interface for IDicomTranscoder
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 19 May 2020 10:17:06 +0200
parents b99acc213937
children 0b3256c3ee14
comparison
equal deleted inserted replaced
3943:b26d25d3c1c7 3944:aae045f802f4
84 const void* data = source.empty() ? NULL : source.c_str(); 84 const void* data = source.empty() ? NULL : source.c_str();
85 85
86 std::set<DicomTransferSyntax> allowedSyntaxes; 86 std::set<DicomTransferSyntax> allowedSyntaxes;
87 allowedSyntaxes.insert(targetSyntax); 87 allowedSyntaxes.insert(targetSyntax);
88 88
89 if (Transcode(target, hasSopInstanceUidChanged, 89 if (TranscodeBuffer(target, hasSopInstanceUidChanged,
90 data, source.size(), allowedSyntaxes, allowNewSopInstanceUid)) 90 data, source.size(), allowedSyntaxes, allowNewSopInstanceUid))
91 { 91 {
92 CheckTargetSyntax(target, allowedSyntaxes); 92 CheckTargetSyntax(target, allowedSyntaxes);
93 return true; 93 return true;
94 } 94 }
95 else 95 else
107 bool allowNewSopInstanceUid) 107 bool allowNewSopInstanceUid)
108 { 108 {
109 bool hasSopInstanceUidChanged; 109 bool hasSopInstanceUidChanged;
110 110
111 std::string target; 111 std::string target;
112 if (Transcode(target, hasSopInstanceUidChanged, 112 if (TranscodeBuffer(target, hasSopInstanceUidChanged,
113 buffer, size, allowedSyntaxes, allowNewSopInstanceUid)) 113 buffer, size, allowedSyntaxes, allowNewSopInstanceUid))
114 { 114 {
115 CheckTargetSyntax(target, allowedSyntaxes); 115 CheckTargetSyntax(target, allowedSyntaxes);
116 116
117 const void* data = target.empty() ? NULL : target.c_str(); 117 const void* data = target.empty() ? NULL : target.c_str();
118 return IDicomTranscoder::TranscodedDicom::CreateFromInternal( 118 return IDicomTranscoder::TranscodedDicom::CreateFromInternal(
121 else 121 else
122 { 122 {
123 return NULL; 123 return NULL;
124 } 124 }
125 } 125 }
126
127
128 bool MemoryBufferTranscoder::Transcode(DicomImage& target,
129 bool& hasSopInstanceUidChanged /* out */,
130 DicomImage& source,
131 const std::set<DicomTransferSyntax>& allowedSyntaxes,
132 bool allowNewSopInstanceUid)
133 {
134 target.Clear();
135
136 std::string buffer;
137 if (TranscodeBuffer(buffer, hasSopInstanceUidChanged, source.GetBufferData(),
138 source.GetBufferSize(), allowedSyntaxes, allowNewSopInstanceUid))
139 {
140 CheckTargetSyntax(buffer, allowedSyntaxes); // For debug only
141 target.AcquireBuffer(buffer);
142 return true;
143 }
144 else
145 {
146 return false;
147 }
148 }
126 } 149 }