comparison Framework/Toolbox/OrthancSlicesLoader.cpp @ 94:7b14c12a3be5 wasm

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 29 May 2017 18:03:30 +0200
parents 5945e81734a3
children d18dcc963930
comparison
equal deleted inserted replaced
93:5945e81734a3 94:7b14c12a3be5
374 info["Stretched"].type() != Json::booleanValue || 374 info["Stretched"].type() != Json::booleanValue ||
375 info["Compression"].asString() != "Jpeg") 375 info["Compression"].asString() != "Jpeg")
376 { 376 {
377 NotifySliceImageError(operation); 377 NotifySliceImageError(operation);
378 return; 378 return;
379 } 379 }
380 380
381 bool isSigned = false; 381 bool isSigned = false;
382 bool isStretched = info["Stretched"].asBool(); 382 bool isStretched = info["Stretched"].asBool();
383 383
384 if (info.isMember("IsSigned")) 384 if (info.isMember("IsSigned"))
385 { 385 {
386 if (info["IsSigned"].type() != Json::booleanValue) 386 if (info["IsSigned"].type() != Json::booleanValue)
387 { 387 {
388 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); 388 NotifySliceImageError(operation);
389 return;
389 } 390 }
390 else 391 else
391 { 392 {
392 isSigned = info["IsSigned"].asBool(); 393 isSigned = info["IsSigned"].asBool();
393 } 394 }
395 396
396 std::string jpeg; 397 std::string jpeg;
397 Orthanc::Toolbox::DecodeBase64(jpeg, info["PixelData"].asString()); 398 Orthanc::Toolbox::DecodeBase64(jpeg, info["PixelData"].asString());
398 399
399 std::auto_ptr<Orthanc::JpegReader> reader(new Orthanc::JpegReader); 400 std::auto_ptr<Orthanc::JpegReader> reader(new Orthanc::JpegReader);
401
400 try 402 try
401 { 403 {
402 reader->ReadFromMemory(jpeg); 404 reader->ReadFromMemory(jpeg);
403 } 405 }
404 catch (Orthanc::OrthancException&) 406 catch (Orthanc::OrthancException&)
480 482
481 float scaling = static_cast<float>(stretchHigh - stretchLow) / 255.0f; 483 float scaling = static_cast<float>(stretchHigh - stretchLow) / 255.0f;
482 float offset = static_cast<float>(stretchLow) / scaling; 484 float offset = static_cast<float>(stretchLow) / scaling;
483 485
484 Orthanc::ImageProcessing::Convert(*image, *reader); 486 Orthanc::ImageProcessing::Convert(*image, *reader);
487 reader.reset(NULL);
488
485 Orthanc::ImageProcessing::ShiftScale(*image, offset, scaling); 489 Orthanc::ImageProcessing::ShiftScale(*image, offset, scaling);
486 490
487 NotifySliceImageSuccess(operation, image.release()); 491 NotifySliceImageSuccess(operation, image.release());
488 } 492 }
489 493
623 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); 627 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
624 } 628 }
625 629
626 // This requires the official Web viewer plugin to be installed! 630 // This requires the official Web viewer plugin to be installed!
627 const Slice& slice = GetSlice(index); 631 const Slice& slice = GetSlice(index);
628 std::string uri = ("web-viewer/instances/jpeg" + 632 std::string uri = ("/web-viewer/instances/jpeg" +
629 boost::lexical_cast<std::string>(value) + 633 boost::lexical_cast<std::string>(value) +
630 "-" + slice.GetOrthancInstanceId() + "_" + 634 "-" + slice.GetOrthancInstanceId() + "_" +
631 boost::lexical_cast<std::string>(slice.GetFrame())); 635 boost::lexical_cast<std::string>(slice.GetFrame()));
632 636
633 orthanc_.ScheduleGetRequest(*webCallback_, uri, 637 orthanc_.ScheduleGetRequest(*webCallback_, uri,