Mercurial > hg > orthanc-stone
annotate Framework/Toolbox/OrthancSlicesLoader.cpp @ 253:8ff70c04c6df am-2
IObservable/IObserver now working in WASM too
author | am@osimis.io |
---|---|
date | Tue, 03 Jul 2018 10:48:47 +0200 |
parents | 40b21c1f8b8d |
children | 9afafb192180 |
rev | line source |
---|---|
73 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
135
e2fe9352f240
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
128
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
73 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
252 | 16 * |
73 | 17 * You should have received a copy of the GNU Affero General Public License |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #include "OrthancSlicesLoader.h" | |
23 | |
24 #include "MessagingToolbox.h" | |
25 | |
212
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
26 #include <Core/Compression/GzipCompressor.h> |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
27 #include <Core/Endianness.h> |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
28 #include <Core/Images/Image.h> |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
29 #include <Core/Images/ImageProcessing.h> |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
30 #include <Core/Images/JpegReader.h> |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
31 #include <Core/Images/PngReader.h> |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
32 #include <Core/Logging.h> |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
33 #include <Core/OrthancException.h> |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
34 #include <Core/Toolbox.h> |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
203
diff
changeset
|
35 #include <Plugins/Samples/Common/FullOrthancDataset.h> |
73 | 36 |
37 #include <boost/lexical_cast.hpp> | |
38 | |
100
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
39 |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
40 |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
41 /** |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
42 * TODO This is a SLOW implementation of base64 decoding, because |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
43 * "Orthanc::Toolbox::DecodeBase64()" does not work properly with |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
44 * WASM. UNDERSTAND WHY. |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
45 * https://stackoverflow.com/a/34571089/881731 |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
46 **/ |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
47 static std::string base64_decode(const std::string &in) |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
48 { |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
49 std::string out; |
252 | 50 |
100
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
51 std::vector<int> T(256,-1); |
252 | 52 for (int i=0; i<64; i++) T["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[i]] = i; |
53 | |
100
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
54 int val=0, valb=-8; |
128 | 55 for (size_t i = 0; i < in.size(); i++) { |
56 unsigned char c = in[i]; | |
100
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
57 if (T[c] == -1) break; |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
58 val = (val<<6) + T[c]; |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
59 valb += 6; |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
60 if (valb>=0) { |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
61 out.push_back(char((val>>valb)&0xFF)); |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
62 valb-=8; |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
63 } |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
64 } |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
65 return out; |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
66 } |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
67 |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
68 |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
69 |
73 | 70 namespace OrthancStone |
71 { | |
72 class OrthancSlicesLoader::Operation : public Orthanc::IDynamicObject | |
73 { | |
74 private: | |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
75 Mode mode_; |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
76 unsigned int frame_; |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
77 unsigned int sliceIndex_; |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
78 const Slice* slice_; |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
79 std::string instanceId_; |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
80 SliceImageQuality quality_; |
252 | 81 |
73 | 82 Operation(Mode mode) : |
83 mode_(mode) | |
84 { | |
85 } | |
252 | 86 |
73 | 87 public: |
88 Mode GetMode() const | |
89 { | |
90 return mode_; | |
91 } | |
252 | 92 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
93 SliceImageQuality GetQuality() const |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
94 { |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
95 assert(mode_ == Mode_LoadImage || |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
96 mode_ == Mode_LoadRawImage); |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
97 return quality_; |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
98 } |
252 | 99 |
73 | 100 unsigned int GetSliceIndex() const |
101 { | |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
102 assert(mode_ == Mode_LoadImage || |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
103 mode_ == Mode_LoadRawImage); |
73 | 104 return sliceIndex_; |
105 } | |
252 | 106 |
73 | 107 const Slice& GetSlice() const |
108 { | |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
109 assert(mode_ == Mode_LoadImage || |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
110 mode_ == Mode_LoadRawImage); |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
111 assert(slice_ != NULL); |
73 | 112 return *slice_; |
113 } | |
252 | 114 |
73 | 115 unsigned int GetFrame() const |
116 { | |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
117 assert(mode_ == Mode_FrameGeometry); |
73 | 118 return frame_; |
119 } | |
252 | 120 |
73 | 121 const std::string& GetInstanceId() const |
122 { | |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
123 assert(mode_ == Mode_FrameGeometry || |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
124 mode_ == Mode_InstanceGeometry); |
73 | 125 return instanceId_; |
126 } | |
252 | 127 |
73 | 128 static Operation* DownloadSeriesGeometry() |
129 { | |
130 return new Operation(Mode_SeriesGeometry); | |
131 } | |
252 | 132 |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
133 static Operation* DownloadInstanceGeometry(const std::string& instanceId) |
73 | 134 { |
135 std::auto_ptr<Operation> operation(new Operation(Mode_InstanceGeometry)); | |
136 operation->instanceId_ = instanceId; | |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
137 return operation.release(); |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
138 } |
252 | 139 |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
140 static Operation* DownloadFrameGeometry(const std::string& instanceId, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
141 unsigned int frame) |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
142 { |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
143 std::auto_ptr<Operation> operation(new Operation(Mode_FrameGeometry)); |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
144 operation->instanceId_ = instanceId; |
73 | 145 operation->frame_ = frame; |
146 return operation.release(); | |
147 } | |
252 | 148 |
73 | 149 static Operation* DownloadSliceImage(unsigned int sliceIndex, |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
150 const Slice& slice, |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
151 SliceImageQuality quality) |
73 | 152 { |
153 std::auto_ptr<Operation> tmp(new Operation(Mode_LoadImage)); | |
154 tmp->sliceIndex_ = sliceIndex; | |
155 tmp->slice_ = &slice; | |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
156 tmp->quality_ = quality; |
73 | 157 return tmp.release(); |
158 } | |
252 | 159 |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
160 static Operation* DownloadSliceRawImage(unsigned int sliceIndex, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
161 const Slice& slice) |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
162 { |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
163 std::auto_ptr<Operation> tmp(new Operation(Mode_LoadRawImage)); |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
164 tmp->sliceIndex_ = sliceIndex; |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
165 tmp->slice_ = &slice; |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
166 tmp->quality_ = SliceImageQuality_Full; |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
167 return tmp.release(); |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
168 } |
73 | 169 }; |
170 | |
252 | 171 |
73 | 172 class OrthancSlicesLoader::WebCallback : public IWebService::ICallback |
173 { | |
174 private: | |
175 OrthancSlicesLoader& that_; | |
252 | 176 |
73 | 177 public: |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
212
diff
changeset
|
178 WebCallback(MessageBroker& broker, OrthancSlicesLoader& that) : |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
212
diff
changeset
|
179 IWebService::ICallback(broker), |
73 | 180 that_(that) |
181 { | |
182 } | |
252 | 183 |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
212
diff
changeset
|
184 virtual void OnHttpRequestSuccess(const std::string& uri, |
252 | 185 const void* answer, |
186 size_t answerSize, | |
187 Orthanc::IDynamicObject* payload) | |
73 | 188 { |
189 std::auto_ptr<Operation> operation(dynamic_cast<Operation*>(payload)); | |
252 | 190 |
73 | 191 switch (operation->GetMode()) |
192 { | |
252 | 193 case Mode_SeriesGeometry: |
194 that_.ParseSeriesGeometry(answer, answerSize); | |
195 break; | |
196 | |
197 case Mode_InstanceGeometry: | |
198 that_.ParseInstanceGeometry(operation->GetInstanceId(), answer, answerSize); | |
199 break; | |
200 | |
201 case Mode_FrameGeometry: | |
202 that_.ParseFrameGeometry(operation->GetInstanceId(), | |
203 operation->GetFrame(), answer, answerSize); | |
204 break; | |
205 | |
206 case Mode_LoadImage: | |
207 switch (operation->GetQuality()) | |
208 { | |
209 case SliceImageQuality_Full: | |
210 that_.ParseSliceImagePng(*operation, answer, answerSize); | |
73 | 211 break; |
252 | 212 |
213 case SliceImageQuality_Jpeg50: | |
214 case SliceImageQuality_Jpeg90: | |
215 case SliceImageQuality_Jpeg95: | |
216 that_.ParseSliceImageJpeg(*operation, answer, answerSize); | |
73 | 217 break; |
218 | |
219 default: | |
220 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
252 | 221 } |
222 | |
223 break; | |
224 | |
225 case Mode_LoadRawImage: | |
226 that_.ParseSliceRawImage(*operation, answer, answerSize); | |
227 break; | |
228 | |
229 default: | |
230 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
73 | 231 } |
252 | 232 } |
233 | |
234 virtual void OnHttpRequestError(const std::string& uri, | |
235 Orthanc::IDynamicObject* payload) | |
236 { | |
237 std::auto_ptr<Operation> operation(dynamic_cast<Operation*>(payload)); | |
238 LOG(ERROR) << "Cannot download " << uri; | |
239 | |
240 switch (operation->GetMode()) | |
241 { | |
242 case Mode_FrameGeometry: | |
243 case Mode_SeriesGeometry: | |
244 that_.userCallback_.OnSliceGeometryError(that_); | |
245 that_.state_ = State_Error; | |
246 break; | |
247 | |
248 case Mode_LoadImage: | |
249 that_.userCallback_.OnSliceImageError(that_, operation->GetSliceIndex(), | |
250 operation->GetSlice(), | |
251 operation->GetQuality()); | |
252 break; | |
253 | |
254 default: | |
255 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
256 } | |
257 } | |
73 | 258 }; |
252 | 259 |
260 void OrthancSlicesLoader::ISliceLoaderObserver::HandleMessage(IObservable& from, const IMessage& message) | |
261 { | |
262 switch (message.GetType()) | |
263 { | |
264 case MessageType_SliceGeometryReady: | |
265 OnSliceGeometryReady(dynamic_cast<OrthancSlicesLoader&>(from)); | |
266 break; | |
267 case MessageType_SliceGeometryError: | |
268 OnSliceGeometryError(dynamic_cast<OrthancSlicesLoader&>(from)); | |
269 break; | |
270 case MessageType_SliceImageReady: | |
271 { | |
272 const SliceImageReadyMessage& msg = dynamic_cast<const SliceImageReadyMessage&>(message); | |
273 OnSliceImageReady(dynamic_cast<OrthancSlicesLoader&>(from), | |
274 msg.sliceIndex_, | |
275 msg.slice_, | |
276 msg.image_, | |
277 msg.effectiveQuality_); | |
278 }; break; | |
279 case MessageType_SliceImageError: | |
280 { | |
281 const SliceImageErrorMessage& msg = dynamic_cast<const SliceImageErrorMessage&>(message); | |
282 OnSliceImageError(dynamic_cast<OrthancSlicesLoader&>(from), | |
283 msg.sliceIndex_, | |
284 msg.slice_, | |
285 msg.effectiveQuality_); | |
286 }; break; | |
287 default: | |
288 VLOG("unhandled message type" << message.GetType()); | |
289 } | |
290 } | |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
291 |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
292 |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
293 void OrthancSlicesLoader::NotifySliceImageSuccess(const Operation& operation, |
99 | 294 std::auto_ptr<Orthanc::ImageAccessor>& image) const |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
295 { |
99 | 296 if (image.get() == NULL) |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
297 { |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
298 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
299 } |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
300 else |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
301 { |
252 | 302 userCallback_.OnSliceImageReady |
303 (*this, operation.GetSliceIndex(), operation.GetSlice(), image, operation.GetQuality()); | |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
304 } |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
305 } |
252 | 306 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
307 |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
308 void OrthancSlicesLoader::NotifySliceImageError(const Operation& operation) const |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
309 { |
252 | 310 userCallback_.OnSliceImageError |
311 (*this, operation.GetSliceIndex(), operation.GetSlice(), operation.GetQuality()); | |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
312 } |
252 | 313 |
314 | |
120
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
315 void OrthancSlicesLoader::SortAndFinalizeSlices() |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
316 { |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
317 bool ok = false; |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
318 |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
319 if (slices_.GetSliceCount() > 0) |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
320 { |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
321 Vector normal; |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
322 if (slices_.SelectNormal(normal)) |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
323 { |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
324 slices_.FilterNormal(normal); |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
325 slices_.SetNormal(normal); |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
326 slices_.Sort(); |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
327 ok = true; |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
328 } |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
329 } |
252 | 330 |
120
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
331 state_ = State_GeometryReady; |
252 | 332 |
120
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
333 if (ok) |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
334 { |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
335 LOG(INFO) << "Loaded a series with " << slices_.GetSliceCount() << " slice(s)"; |
252 | 336 userCallback_.OnSliceGeometryReady(*this); |
120
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
337 } |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
338 else |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
339 { |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
340 LOG(ERROR) << "This series is empty"; |
252 | 341 userCallback_.OnSliceGeometryError(*this); |
120
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
342 } |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
343 } |
252 | 344 |
73 | 345 |
346 void OrthancSlicesLoader::ParseSeriesGeometry(const void* answer, | |
347 size_t size) | |
348 { | |
349 Json::Value series; | |
350 if (!MessagingToolbox::ParseJson(series, answer, size) || | |
351 series.type() != Json::objectValue) | |
352 { | |
252 | 353 userCallback_.OnSliceGeometryError(*this); |
73 | 354 return; |
355 } | |
252 | 356 |
73 | 357 Json::Value::Members instances = series.getMemberNames(); |
252 | 358 |
73 | 359 slices_.Reserve(instances.size()); |
252 | 360 |
73 | 361 for (size_t i = 0; i < instances.size(); i++) |
362 { | |
363 OrthancPlugins::FullOrthancDataset dataset(series[instances[i]]); | |
252 | 364 |
118
a4d0b6c82b29
using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
365 Orthanc::DicomMap dicom; |
a4d0b6c82b29
using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
366 MessagingToolbox::ConvertDataset(dicom, dataset); |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
367 |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
368 unsigned int frames; |
118
a4d0b6c82b29
using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
369 if (!dicom.ParseUnsignedInteger32(frames, Orthanc::DICOM_TAG_NUMBER_OF_FRAMES)) |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
370 { |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
371 frames = 1; |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
372 } |
252 | 373 |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
374 for (unsigned int frame = 0; frame < frames; frame++) |
73 | 375 { |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
376 std::auto_ptr<Slice> slice(new Slice); |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
377 if (slice->ParseOrthancFrame(dicom, instances[i], frame)) |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
378 { |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
379 slices_.AddSlice(slice.release()); |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
380 } |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
381 else |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
382 { |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
383 LOG(WARNING) << "Skipping invalid frame " << frame << " within instance " << instances[i]; |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
384 } |
73 | 385 } |
386 } | |
252 | 387 |
120
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
388 SortAndFinalizeSlices(); |
73 | 389 } |
252 | 390 |
391 | |
73 | 392 void OrthancSlicesLoader::ParseInstanceGeometry(const std::string& instanceId, |
393 const void* answer, | |
394 size_t size) | |
395 { | |
396 Json::Value tags; | |
397 if (!MessagingToolbox::ParseJson(tags, answer, size) || | |
398 tags.type() != Json::objectValue) | |
399 { | |
252 | 400 userCallback_.OnSliceGeometryError(*this); |
73 | 401 return; |
402 } | |
252 | 403 |
73 | 404 OrthancPlugins::FullOrthancDataset dataset(tags); |
252 | 405 |
118
a4d0b6c82b29
using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
406 Orthanc::DicomMap dicom; |
a4d0b6c82b29
using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
407 MessagingToolbox::ConvertDataset(dicom, dataset); |
252 | 408 |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
409 unsigned int frames; |
118
a4d0b6c82b29
using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
410 if (!dicom.ParseUnsignedInteger32(frames, Orthanc::DICOM_TAG_NUMBER_OF_FRAMES)) |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
411 { |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
412 frames = 1; |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
413 } |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
414 |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
415 LOG(INFO) << "Instance " << instanceId << " contains " << frames << " frame(s)"; |
252 | 416 |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
417 for (unsigned int frame = 0; frame < frames; frame++) |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
418 { |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
419 std::auto_ptr<Slice> slice(new Slice); |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
420 if (slice->ParseOrthancFrame(dicom, instanceId, frame)) |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
421 { |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
422 slices_.AddSlice(slice.release()); |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
423 } |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
424 else |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
425 { |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
426 LOG(WARNING) << "Skipping invalid multi-frame instance " << instanceId; |
252 | 427 userCallback_.OnSliceGeometryError(*this); |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
428 return; |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
429 } |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
430 } |
252 | 431 |
120
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
432 SortAndFinalizeSlices(); |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
433 } |
252 | 434 |
435 | |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
436 void OrthancSlicesLoader::ParseFrameGeometry(const std::string& instanceId, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
437 unsigned int frame, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
438 const void* answer, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
439 size_t size) |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
440 { |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
441 Json::Value tags; |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
442 if (!MessagingToolbox::ParseJson(tags, answer, size) || |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
443 tags.type() != Json::objectValue) |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
444 { |
252 | 445 userCallback_.OnSliceGeometryError(*this); |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
446 return; |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
447 } |
252 | 448 |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
449 OrthancPlugins::FullOrthancDataset dataset(tags); |
252 | 450 |
73 | 451 state_ = State_GeometryReady; |
252 | 452 |
118
a4d0b6c82b29
using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
453 Orthanc::DicomMap dicom; |
a4d0b6c82b29
using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
117
diff
changeset
|
454 MessagingToolbox::ConvertDataset(dicom, dataset); |
252 | 455 |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
456 std::auto_ptr<Slice> slice(new Slice); |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
457 if (slice->ParseOrthancFrame(dicom, instanceId, frame)) |
73 | 458 { |
459 LOG(INFO) << "Loaded instance " << instanceId; | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
460 slices_.AddSlice(slice.release()); |
252 | 461 userCallback_.OnSliceGeometryReady(*this); |
73 | 462 } |
463 else | |
464 { | |
465 LOG(WARNING) << "Skipping invalid instance " << instanceId; | |
252 | 466 userCallback_.OnSliceGeometryError(*this); |
73 | 467 } |
468 } | |
252 | 469 |
470 | |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
471 void OrthancSlicesLoader::ParseSliceImagePng(const Operation& operation, |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
472 const void* answer, |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
473 size_t size) |
73 | 474 { |
99 | 475 std::auto_ptr<Orthanc::ImageAccessor> image; |
252 | 476 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
477 try |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
478 { |
99 | 479 image.reset(new Orthanc::PngReader); |
480 dynamic_cast<Orthanc::PngReader&>(*image).ReadFromMemory(answer, size); | |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
481 } |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
482 catch (Orthanc::OrthancException&) |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
483 { |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
484 NotifySliceImageError(operation); |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
485 return; |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
486 } |
252 | 487 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
488 if (image->GetWidth() != operation.GetSlice().GetWidth() || |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
489 image->GetHeight() != operation.GetSlice().GetHeight()) |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
490 { |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
491 NotifySliceImageError(operation); |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
492 return; |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
493 } |
252 | 494 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
495 if (operation.GetSlice().GetConverter().GetExpectedPixelFormat() == |
73 | 496 Orthanc::PixelFormat_SignedGrayscale16) |
497 { | |
498 if (image->GetFormat() == Orthanc::PixelFormat_Grayscale16) | |
499 { | |
500 image->SetFormat(Orthanc::PixelFormat_SignedGrayscale16); | |
501 } | |
502 else | |
503 { | |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
504 NotifySliceImageError(operation); |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
505 return; |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
506 } |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
507 } |
252 | 508 |
99 | 509 NotifySliceImageSuccess(operation, image); |
252 | 510 } |
511 | |
100
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
512 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
513 void OrthancSlicesLoader::ParseSliceImageJpeg(const Operation& operation, |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
514 const void* answer, |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
515 size_t size) |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
516 { |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
517 Json::Value encoded; |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
518 if (!MessagingToolbox::ParseJson(encoded, answer, size) || |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
519 encoded.type() != Json::objectValue || |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
520 !encoded.isMember("Orthanc") || |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
521 encoded["Orthanc"].type() != Json::objectValue) |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
522 { |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
523 NotifySliceImageError(operation); |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
524 return; |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
525 } |
252 | 526 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
527 Json::Value& info = encoded["Orthanc"]; |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
528 if (!info.isMember("PixelData") || |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
529 !info.isMember("Stretched") || |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
530 !info.isMember("Compression") || |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
531 info["Compression"].type() != Json::stringValue || |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
532 info["PixelData"].type() != Json::stringValue || |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
533 info["Stretched"].type() != Json::booleanValue || |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
534 info["Compression"].asString() != "Jpeg") |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
535 { |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
536 NotifySliceImageError(operation); |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
537 return; |
94 | 538 } |
252 | 539 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
540 bool isSigned = false; |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
541 bool isStretched = info["Stretched"].asBool(); |
252 | 542 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
543 if (info.isMember("IsSigned")) |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
544 { |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
545 if (info["IsSigned"].type() != Json::booleanValue) |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
546 { |
94 | 547 NotifySliceImageError(operation); |
548 return; | |
252 | 549 } |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
550 else |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
551 { |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
552 isSigned = info["IsSigned"].asBool(); |
73 | 553 } |
554 } | |
252 | 555 |
99 | 556 std::auto_ptr<Orthanc::ImageAccessor> reader; |
252 | 557 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
558 { |
100
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
559 std::string jpeg; |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
560 //Orthanc::Toolbox::DecodeBase64(jpeg, info["PixelData"].asString()); |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
561 jpeg = base64_decode(info["PixelData"].asString()); |
252 | 562 |
100
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
563 try |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
564 { |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
565 reader.reset(new Orthanc::JpegReader); |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
566 dynamic_cast<Orthanc::JpegReader&>(*reader).ReadFromMemory(jpeg); |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
567 } |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
568 catch (Orthanc::OrthancException&) |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
569 { |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
570 NotifySliceImageError(operation); |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
571 return; |
166a555becbf
fix jpeg decoding in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
99
diff
changeset
|
572 } |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
573 } |
252 | 574 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
575 Orthanc::PixelFormat expectedFormat = |
252 | 576 operation.GetSlice().GetConverter().GetExpectedPixelFormat(); |
577 | |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
578 if (reader->GetFormat() == Orthanc::PixelFormat_RGB24) // This is a color image |
73 | 579 { |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
580 if (expectedFormat != Orthanc::PixelFormat_RGB24) |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
581 { |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
582 NotifySliceImageError(operation); |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
583 return; |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
584 } |
252 | 585 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
586 if (isSigned || isStretched) |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
587 { |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
588 NotifySliceImageError(operation); |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
589 return; |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
590 } |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
591 else |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
592 { |
99 | 593 NotifySliceImageSuccess(operation, reader); |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
594 return; |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
595 } |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
596 } |
252 | 597 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
598 if (reader->GetFormat() != Orthanc::PixelFormat_Grayscale8) |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
599 { |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
600 NotifySliceImageError(operation); |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
601 return; |
73 | 602 } |
252 | 603 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
604 if (!isStretched) |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
605 { |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
606 if (expectedFormat != reader->GetFormat()) |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
607 { |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
608 NotifySliceImageError(operation); |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
609 return; |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
610 } |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
611 else |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
612 { |
99 | 613 NotifySliceImageSuccess(operation, reader); |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
614 return; |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
615 } |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
616 } |
252 | 617 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
618 int32_t stretchLow = 0; |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
619 int32_t stretchHigh = 0; |
252 | 620 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
621 if (!info.isMember("StretchLow") || |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
622 !info.isMember("StretchHigh") || |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
623 info["StretchLow"].type() != Json::intValue || |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
624 info["StretchHigh"].type() != Json::intValue) |
73 | 625 { |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
626 NotifySliceImageError(operation); |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
627 return; |
73 | 628 } |
252 | 629 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
630 stretchLow = info["StretchLow"].asInt(); |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
631 stretchHigh = info["StretchHigh"].asInt(); |
252 | 632 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
633 if (stretchLow < -32768 || |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
634 stretchHigh > 65535 || |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
635 (stretchLow < 0 && stretchHigh > 32767)) |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
636 { |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
637 // This range cannot be represented with a uint16_t or an int16_t |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
638 NotifySliceImageError(operation); |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
639 return; |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
640 } |
252 | 641 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
642 // Decode a grayscale JPEG 8bpp image coming from the Web viewer |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
643 std::auto_ptr<Orthanc::ImageAccessor> image |
252 | 644 (new Orthanc::Image(expectedFormat, reader->GetWidth(), reader->GetHeight(), false)); |
645 | |
203 | 646 Orthanc::ImageProcessing::Convert(*image, *reader); |
647 reader.reset(NULL); | |
252 | 648 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
649 float scaling = static_cast<float>(stretchHigh - stretchLow) / 255.0f; |
252 | 650 |
203 | 651 if (!LinearAlgebra::IsCloseToZero(scaling)) |
652 { | |
653 float offset = static_cast<float>(stretchLow) / scaling; | |
654 Orthanc::ImageProcessing::ShiftScale(*image, offset, scaling, true); | |
655 } | |
252 | 656 |
99 | 657 NotifySliceImageSuccess(operation, image); |
73 | 658 } |
252 | 659 |
660 | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
661 class StringImage : |
252 | 662 public Orthanc::ImageAccessor, |
663 public boost::noncopyable | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
664 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
665 private: |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
666 std::string buffer_; |
73 | 667 |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
668 public: |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
669 StringImage(Orthanc::PixelFormat format, |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
670 unsigned int width, |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
671 unsigned int height, |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
672 std::string& buffer) |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
673 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
674 if (buffer.size() != Orthanc::GetBytesPerPixel(format) * width * height) |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
675 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
676 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
677 } |
252 | 678 |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
679 buffer_.swap(buffer); // The source buffer is now empty |
252 | 680 |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
681 void* data = (buffer_.empty() ? NULL : &buffer_[0]); |
252 | 682 |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
683 AssignWritable(format, width, height, |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
684 Orthanc::GetBytesPerPixel(format) * width, data); |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
685 } |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
686 }; |
252 | 687 |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
688 |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
689 void OrthancSlicesLoader::ParseSliceRawImage(const Operation& operation, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
690 const void* answer, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
691 size_t size) |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
692 { |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
693 Orthanc::GzipCompressor compressor; |
252 | 694 |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
695 std::string raw; |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
696 compressor.Uncompress(raw, answer, size); |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
697 |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
698 const Orthanc::DicomImageInformation& info = operation.GetSlice().GetImageInformation(); |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
699 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
700 if (info.GetBitsAllocated() == 32 && |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
701 info.GetBitsStored() == 32 && |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
702 info.GetHighBit() == 31 && |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
703 info.GetChannelCount() == 1 && |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
704 !info.IsSigned() && |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
705 info.GetPhotometricInterpretation() == Orthanc::PhotometricInterpretation_Monochrome2 && |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
706 raw.size() == info.GetWidth() * info.GetHeight() * 4) |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
707 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
708 // This is the case of RT-DOSE (uint32_t values) |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
709 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
710 std::auto_ptr<Orthanc::ImageAccessor> image |
252 | 711 (new StringImage(Orthanc::PixelFormat_Grayscale32, info.GetWidth(), |
712 info.GetHeight(), raw)); | |
713 | |
120
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
714 // TODO - Only for big endian |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
715 for (unsigned int y = 0; y < image->GetHeight(); y++) |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
716 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
717 uint32_t *p = reinterpret_cast<uint32_t*>(image->GetRow(y)); |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
718 for (unsigned int x = 0; x < image->GetWidth(); x++, p++) |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
719 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
720 *p = le32toh(*p); |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
721 } |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
722 } |
252 | 723 |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
724 NotifySliceImageSuccess(operation, image); |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
725 } |
120
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
726 else if (info.GetBitsAllocated() == 16 && |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
727 info.GetBitsStored() == 16 && |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
728 info.GetHighBit() == 15 && |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
729 info.GetChannelCount() == 1 && |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
730 !info.IsSigned() && |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
731 info.GetPhotometricInterpretation() == Orthanc::PhotometricInterpretation_Monochrome2 && |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
732 raw.size() == info.GetWidth() * info.GetHeight() * 2) |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
733 { |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
734 std::auto_ptr<Orthanc::ImageAccessor> image |
252 | 735 (new StringImage(Orthanc::PixelFormat_Grayscale16, info.GetWidth(), |
736 info.GetHeight(), raw)); | |
737 | |
120
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
738 // TODO - Big endian ? |
252 | 739 |
120
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
740 NotifySliceImageSuccess(operation, image); |
063f7f3d9f14
fix 3d locations of the doses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
741 } |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
742 else |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
743 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
744 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
745 } |
252 | 746 |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
747 } |
252 | 748 |
749 | |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
212
diff
changeset
|
750 OrthancSlicesLoader::OrthancSlicesLoader(MessageBroker& broker, |
252 | 751 ISliceLoaderObserver& callback, |
73 | 752 IWebService& orthanc) : |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
212
diff
changeset
|
753 webCallback_(new WebCallback(broker, *this)), |
73 | 754 userCallback_(callback), |
755 orthanc_(orthanc), | |
756 state_(State_Initialization) | |
757 { | |
758 } | |
252 | 759 |
73 | 760 |
761 void OrthancSlicesLoader::ScheduleLoadSeries(const std::string& seriesId) | |
762 { | |
763 if (state_ != State_Initialization) | |
764 { | |
765 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
766 } | |
767 else | |
768 { | |
769 state_ = State_LoadingGeometry; | |
770 std::string uri = "/series/" + seriesId + "/instances-tags"; | |
771 orthanc_.ScheduleGetRequest(*webCallback_, uri, Operation::DownloadSeriesGeometry()); | |
772 } | |
773 } | |
252 | 774 |
775 | |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
776 void OrthancSlicesLoader::ScheduleLoadInstance(const std::string& instanceId) |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
777 { |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
778 if (state_ != State_Initialization) |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
779 { |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
780 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
781 } |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
782 else |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
783 { |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
784 state_ = State_LoadingGeometry; |
252 | 785 |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
786 // Tag "3004-000c" is "Grid Frame Offset Vector", which is |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
787 // mandatory to read RT DOSE, but is too long to be returned by default |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
788 std::string uri = "/instances/" + instanceId + "/tags?ignore-length=3004-000c"; |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
789 orthanc_.ScheduleGetRequest |
252 | 790 (*webCallback_, uri, Operation::DownloadInstanceGeometry(instanceId)); |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
791 } |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
792 } |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
793 |
252 | 794 |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
795 void OrthancSlicesLoader::ScheduleLoadFrame(const std::string& instanceId, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
796 unsigned int frame) |
73 | 797 { |
798 if (state_ != State_Initialization) | |
799 { | |
800 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
801 } | |
802 else | |
803 { | |
804 state_ = State_LoadingGeometry; | |
805 std::string uri = "/instances/" + instanceId + "/tags"; | |
806 orthanc_.ScheduleGetRequest | |
252 | 807 (*webCallback_, uri, Operation::DownloadFrameGeometry(instanceId, frame)); |
73 | 808 } |
809 } | |
810 | |
252 | 811 |
77 | 812 bool OrthancSlicesLoader::IsGeometryReady() const |
813 { | |
814 return state_ == State_GeometryReady; | |
815 } | |
252 | 816 |
817 | |
73 | 818 size_t OrthancSlicesLoader::GetSliceCount() const |
819 { | |
820 if (state_ != State_GeometryReady) | |
821 { | |
822 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
823 } | |
252 | 824 |
73 | 825 return slices_.GetSliceCount(); |
826 } | |
252 | 827 |
73 | 828 |
829 const Slice& OrthancSlicesLoader::GetSlice(size_t index) const | |
830 { | |
831 if (state_ != State_GeometryReady) | |
832 { | |
833 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
834 } | |
252 | 835 |
73 | 836 return slices_.GetSlice(index); |
837 } | |
838 | |
252 | 839 |
77 | 840 bool OrthancSlicesLoader::LookupSlice(size_t& index, |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
100
diff
changeset
|
841 const CoordinateSystem3D& plane) const |
77 | 842 { |
843 if (state_ != State_GeometryReady) | |
844 { | |
845 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
846 } | |
252 | 847 |
77 | 848 return slices_.LookupSlice(index, plane); |
849 } | |
850 | |
252 | 851 |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
852 void OrthancSlicesLoader::ScheduleSliceImagePng(const Slice& slice, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
853 size_t index) |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
854 { |
252 | 855 std::string uri = ("/instances/" + slice.GetOrthancInstanceId() + "/frames/" + |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
856 boost::lexical_cast<std::string>(slice.GetFrame())); |
252 | 857 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
858 switch (slice.GetConverter().GetExpectedPixelFormat()) |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
859 { |
252 | 860 case Orthanc::PixelFormat_RGB24: |
861 uri += "/preview"; | |
862 break; | |
863 | |
864 case Orthanc::PixelFormat_Grayscale16: | |
865 uri += "/image-uint16"; | |
866 break; | |
867 | |
868 case Orthanc::PixelFormat_SignedGrayscale16: | |
869 uri += "/image-int16"; | |
870 break; | |
871 | |
872 default: | |
873 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
874 } |
252 | 875 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
876 orthanc_.ScheduleGetRequest(*webCallback_, uri, |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
877 Operation::DownloadSliceImage(index, slice, SliceImageQuality_Full)); |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
878 } |
252 | 879 |
880 | |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
881 void OrthancSlicesLoader::ScheduleSliceImageJpeg(const Slice& slice, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
882 size_t index, |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
883 SliceImageQuality quality) |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
884 { |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
885 unsigned int value; |
252 | 886 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
887 switch (quality) |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
888 { |
252 | 889 case SliceImageQuality_Jpeg50: |
890 value = 50; | |
891 break; | |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
892 |
252 | 893 case SliceImageQuality_Jpeg90: |
894 value = 90; | |
895 break; | |
896 | |
897 case SliceImageQuality_Jpeg95: | |
898 value = 95; | |
899 break; | |
900 | |
901 default: | |
902 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
903 } |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
904 |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
905 // This requires the official Web viewer plugin to be installed! |
252 | 906 std::string uri = ("/web-viewer/instances/jpeg" + |
907 boost::lexical_cast<std::string>(value) + | |
908 "-" + slice.GetOrthancInstanceId() + "_" + | |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
909 boost::lexical_cast<std::string>(slice.GetFrame())); |
252 | 910 |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
911 orthanc_.ScheduleGetRequest(*webCallback_, uri, |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
912 Operation::DownloadSliceImage(index, slice, quality)); |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
913 } |
252 | 914 |
915 | |
916 | |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
917 void OrthancSlicesLoader::ScheduleLoadSliceImage(size_t index, |
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
918 SliceImageQuality quality) |
73 | 919 { |
920 if (state_ != State_GeometryReady) | |
921 { | |
922 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | |
923 } | |
252 | 924 |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
925 const Slice& slice = GetSlice(index); |
252 | 926 |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
927 if (slice.HasOrthancDecoding()) |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
928 { |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
929 if (quality == SliceImageQuality_Full) |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
930 { |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
931 ScheduleSliceImagePng(slice, index); |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
932 } |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
933 else |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
934 { |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
935 ScheduleSliceImageJpeg(slice, index, quality); |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
936 } |
93
5945e81734a3
decoding of JPEG images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
77
diff
changeset
|
937 } |
73 | 938 else |
939 { | |
252 | 940 std::string uri = ("/instances/" + slice.GetOrthancInstanceId() + "/frames/" + |
117
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
941 boost::lexical_cast<std::string>(slice.GetFrame()) + "/raw.gz"); |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
942 orthanc_.ScheduleGetRequest(*webCallback_, uri, |
42c05a3baee3
loading multi-frame instances as 3D volumes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
943 Operation::DownloadSliceRawImage(index, slice)); |
73 | 944 } |
945 } | |
946 } |