comparison Framework/Oracle/GetOrthancWebViewerJpegCommand.cpp @ 1098:17660df24c36 broker

simplification of IOracleRunner
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 25 Oct 2019 13:01:24 +0200
parents 81b29bc7c3d4
children 87fbeb823375
comparison
equal deleted inserted replaced
1097:4383382db01d 1098:17660df24c36
74 return ("/web-viewer/instances/jpeg" + boost::lexical_cast<std::string>(quality_) + 74 return ("/web-viewer/instances/jpeg" + boost::lexical_cast<std::string>(quality_) +
75 "-" + instanceId_ + "_" + boost::lexical_cast<std::string>(frame_)); 75 "-" + instanceId_ + "_" + boost::lexical_cast<std::string>(frame_));
76 } 76 }
77 77
78 78
79 void GetOrthancWebViewerJpegCommand::ProcessHttpAnswer(IMessageEmitter& emitter, 79 IMessage* GetOrthancWebViewerJpegCommand::ProcessHttpAnswer(const std::string& answer) const
80 boost::weak_ptr<IObserver>& receiver,
81 const std::string& answer) const
82 { 80 {
83 // This code comes from older "OrthancSlicesLoader::ParseSliceImageJpeg()" 81 // This code comes from older "OrthancSlicesLoader::ParseSliceImageJpeg()"
84 82
85 Json::Value encoded; 83 Json::Value encoded;
86 84
147 { 145 {
148 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); 146 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
149 } 147 }
150 else 148 else
151 { 149 {
152 SuccessMessage message(*this, reader.release()); 150 return new SuccessMessage(*this, reader.release());
153 emitter.EmitMessage(receiver, message);
154 return;
155 } 151 }
156 } 152 }
157 153
158 if (reader->GetFormat() != Orthanc::PixelFormat_Grayscale8) 154 if (reader->GetFormat() != Orthanc::PixelFormat_Grayscale8)
159 { 155 {
166 { 162 {
167 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); 163 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
168 } 164 }
169 else 165 else
170 { 166 {
171 SuccessMessage message(*this, reader.release()); 167 return new SuccessMessage(*this, reader.release());
172 emitter.EmitMessage(receiver, message);
173 return;
174 } 168 }
175 } 169 }
176 170
177 int32_t stretchLow = 0; 171 int32_t stretchLow = 0;
178 int32_t stretchHigh = 0; 172 int32_t stretchHigh = 0;
208 if (!LinearAlgebra::IsCloseToZero(scaling)) 202 if (!LinearAlgebra::IsCloseToZero(scaling))
209 { 203 {
210 float offset = static_cast<float>(stretchLow) / scaling; 204 float offset = static_cast<float>(stretchLow) / scaling;
211 Orthanc::ImageProcessing::ShiftScale(*image, offset, scaling, true); 205 Orthanc::ImageProcessing::ShiftScale(*image, offset, scaling, true);
212 } 206 }
213 207
214 SuccessMessage message(*this, image.release()); 208 return new SuccessMessage(*this, image.release());
215 emitter.EmitMessage(receiver, message);
216 } 209 }
217 } 210 }