Mercurial > hg > orthanc-stone
comparison Framework/Toolbox/OrthancSlicesLoader.cpp @ 99:efd9ef2b67f1 wasm
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 30 May 2017 21:08:31 +0200 |
parents | d18dcc963930 |
children | 166a555becbf |
comparison
equal
deleted
inserted
replaced
98:a33abae66344 | 99:efd9ef2b67f1 |
---|---|
195 }; | 195 }; |
196 | 196 |
197 | 197 |
198 | 198 |
199 void OrthancSlicesLoader::NotifySliceImageSuccess(const Operation& operation, | 199 void OrthancSlicesLoader::NotifySliceImageSuccess(const Operation& operation, |
200 Orthanc::ImageAccessor* image) const | 200 std::auto_ptr<Orthanc::ImageAccessor>& image) const |
201 { | 201 { |
202 if (image == NULL) | 202 if (image.get() == NULL) |
203 { | 203 { |
204 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); | 204 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
205 } | 205 } |
206 else | 206 else |
207 { | 207 { |
311 | 311 |
312 void OrthancSlicesLoader::ParseSliceImagePng(const Operation& operation, | 312 void OrthancSlicesLoader::ParseSliceImagePng(const Operation& operation, |
313 const void* answer, | 313 const void* answer, |
314 size_t size) | 314 size_t size) |
315 { | 315 { |
316 std::auto_ptr<Orthanc::PngReader> image(new Orthanc::PngReader); | 316 std::auto_ptr<Orthanc::ImageAccessor> image; |
317 | 317 |
318 bool ok = false; | |
319 | |
320 try | 318 try |
321 { | 319 { |
322 image->ReadFromMemory(answer, size); | 320 image.reset(new Orthanc::PngReader); |
321 dynamic_cast<Orthanc::PngReader&>(*image).ReadFromMemory(answer, size); | |
323 } | 322 } |
324 catch (Orthanc::OrthancException&) | 323 catch (Orthanc::OrthancException&) |
325 { | 324 { |
326 NotifySliceImageError(operation); | 325 NotifySliceImageError(operation); |
327 return; | 326 return; |
346 NotifySliceImageError(operation); | 345 NotifySliceImageError(operation); |
347 return; | 346 return; |
348 } | 347 } |
349 } | 348 } |
350 | 349 |
351 NotifySliceImageSuccess(operation, image.release()); | 350 NotifySliceImageSuccess(operation, image); |
352 } | 351 } |
353 | 352 |
354 | 353 |
355 void OrthancSlicesLoader::ParseSliceImageJpeg(const Operation& operation, | 354 void OrthancSlicesLoader::ParseSliceImageJpeg(const Operation& operation, |
356 const void* answer, | 355 const void* answer, |
396 } | 395 } |
397 | 396 |
398 std::string jpeg; | 397 std::string jpeg; |
399 Orthanc::Toolbox::DecodeBase64(jpeg, info["PixelData"].asString()); | 398 Orthanc::Toolbox::DecodeBase64(jpeg, info["PixelData"].asString()); |
400 | 399 |
401 std::auto_ptr<Orthanc::JpegReader> reader(new Orthanc::JpegReader); | 400 std::auto_ptr<Orthanc::ImageAccessor> reader; |
402 | 401 |
403 try | 402 try |
404 { | 403 { |
405 reader->ReadFromMemory(jpeg); | 404 reader.reset(new Orthanc::JpegReader); |
405 dynamic_cast<Orthanc::JpegReader&>(*reader).ReadFromMemory(jpeg); | |
406 } | 406 } |
407 catch (Orthanc::OrthancException&) | 407 catch (Orthanc::OrthancException&) |
408 { | 408 { |
409 NotifySliceImageError(operation); | 409 NotifySliceImageError(operation); |
410 return; | 410 return; |
426 NotifySliceImageError(operation); | 426 NotifySliceImageError(operation); |
427 return; | 427 return; |
428 } | 428 } |
429 else | 429 else |
430 { | 430 { |
431 NotifySliceImageSuccess(operation, reader.release()); | 431 NotifySliceImageSuccess(operation, reader); |
432 return; | 432 return; |
433 } | 433 } |
434 } | 434 } |
435 | 435 |
436 if (reader->GetFormat() != Orthanc::PixelFormat_Grayscale8) | 436 if (reader->GetFormat() != Orthanc::PixelFormat_Grayscale8) |
446 NotifySliceImageError(operation); | 446 NotifySliceImageError(operation); |
447 return; | 447 return; |
448 } | 448 } |
449 else | 449 else |
450 { | 450 { |
451 NotifySliceImageSuccess(operation, reader.release()); | 451 NotifySliceImageSuccess(operation, reader); |
452 return; | 452 return; |
453 } | 453 } |
454 } | 454 } |
455 | 455 |
456 int32_t stretchLow = 0; | 456 int32_t stretchLow = 0; |
487 Orthanc::ImageProcessing::Convert(*image, *reader); | 487 Orthanc::ImageProcessing::Convert(*image, *reader); |
488 reader.reset(NULL); | 488 reader.reset(NULL); |
489 | 489 |
490 Orthanc::ImageProcessing::ShiftScale(*image, offset, scaling); | 490 Orthanc::ImageProcessing::ShiftScale(*image, offset, scaling); |
491 | 491 |
492 NotifySliceImageSuccess(operation, image.release()); | 492 NotifySliceImageSuccess(operation, image); |
493 } | 493 } |
494 | 494 |
495 | 495 |
496 OrthancSlicesLoader::OrthancSlicesLoader(ICallback& callback, | 496 OrthancSlicesLoader::OrthancSlicesLoader(ICallback& callback, |
497 IWebService& orthanc) : | 497 IWebService& orthanc) : |