Mercurial > hg > orthanc-webviewer
comparison Plugin/DecodedImageAdapter.cpp @ 145:d850500b8ca6
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 08 Nov 2016 10:15:05 +0100 |
parents | f99adade8b77 |
children | 5dc54316d68b |
comparison
equal
deleted
inserted
replaced
144:daf99382bc18 | 145:d850500b8ca6 |
---|---|
282 { | 282 { |
283 Orthanc::ImageAccessor accessor; | 283 Orthanc::ImageAccessor accessor; |
284 accessor.AssignReadOnly(OrthancPlugins::Convert(image.GetFormat()), image.GetWidth(), | 284 accessor.AssignReadOnly(OrthancPlugins::Convert(image.GetFormat()), image.GetWidth(), |
285 image.GetHeight(), image.GetPitch(), image.GetBuffer()); | 285 image.GetHeight(), image.GetPitch(), image.GetBuffer()); |
286 | 286 |
287 Orthanc::ImageBuffer buffer; | 287 std::auto_ptr<Orthanc::ImageBuffer> buffer; |
288 buffer.SetMinimalPitchForced(true); | |
289 | 288 |
290 Orthanc::ImageAccessor converted; | 289 Orthanc::ImageAccessor converted; |
291 | 290 |
292 switch (accessor.GetFormat()) | 291 switch (accessor.GetFormat()) |
293 { | 292 { |
295 converted = accessor; | 294 converted = accessor; |
296 break; | 295 break; |
297 | 296 |
298 case Orthanc::PixelFormat_Grayscale8: | 297 case Orthanc::PixelFormat_Grayscale8: |
299 case Orthanc::PixelFormat_Grayscale16: | 298 case Orthanc::PixelFormat_Grayscale16: |
300 buffer.SetFormat(Orthanc::PixelFormat_Grayscale16); | 299 buffer.reset(new Orthanc::ImageBuffer(Orthanc::PixelFormat_Grayscale16, |
301 buffer.SetWidth(accessor.GetWidth()); | 300 accessor.GetWidth(), |
302 buffer.SetHeight(accessor.GetHeight()); | 301 accessor.GetHeight(), |
303 converted = buffer.GetAccessor(); | 302 true /* force minimal pitch */)); |
303 converted = buffer->GetAccessor(); | |
304 Orthanc::ImageProcessing::Convert(converted, accessor); | 304 Orthanc::ImageProcessing::Convert(converted, accessor); |
305 break; | 305 break; |
306 | 306 |
307 case Orthanc::PixelFormat_SignedGrayscale16: | 307 case Orthanc::PixelFormat_SignedGrayscale16: |
308 converted = accessor; | 308 converted = accessor; |
384 { | 384 { |
385 Orthanc::ImageAccessor accessor; | 385 Orthanc::ImageAccessor accessor; |
386 accessor.AssignReadOnly(OrthancPlugins::Convert(image.GetFormat()), image.GetWidth(), | 386 accessor.AssignReadOnly(OrthancPlugins::Convert(image.GetFormat()), image.GetWidth(), |
387 image.GetHeight(), image.GetPitch(), image.GetBuffer()); | 387 image.GetHeight(), image.GetPitch(), image.GetBuffer()); |
388 | 388 |
389 Orthanc::ImageBuffer buffer; | 389 std::auto_ptr<Orthanc::ImageBuffer> buffer; |
390 buffer.SetMinimalPitchForced(true); | |
391 | 390 |
392 Orthanc::ImageAccessor converted; | 391 Orthanc::ImageAccessor converted; |
393 | 392 |
394 if (accessor.GetFormat() == Orthanc::PixelFormat_Grayscale8 || | 393 if (accessor.GetFormat() == Orthanc::PixelFormat_Grayscale8 || |
395 accessor.GetFormat() == Orthanc::PixelFormat_RGB24) | 394 accessor.GetFormat() == Orthanc::PixelFormat_RGB24) |
399 } | 398 } |
400 else if (accessor.GetFormat() == Orthanc::PixelFormat_Grayscale16 || | 399 else if (accessor.GetFormat() == Orthanc::PixelFormat_Grayscale16 || |
401 accessor.GetFormat() == Orthanc::PixelFormat_SignedGrayscale16) | 400 accessor.GetFormat() == Orthanc::PixelFormat_SignedGrayscale16) |
402 { | 401 { |
403 result["Orthanc"]["Stretched"] = true; | 402 result["Orthanc"]["Stretched"] = true; |
404 buffer.SetFormat(Orthanc::PixelFormat_Grayscale8); | 403 |
405 buffer.SetWidth(accessor.GetWidth()); | 404 buffer.reset(new Orthanc::ImageBuffer(Orthanc::PixelFormat_Grayscale8, |
406 buffer.SetHeight(accessor.GetHeight()); | 405 accessor.GetWidth(), |
407 converted = buffer.GetAccessor(); | 406 accessor.GetHeight(), |
407 true /* force minimal pitch */)); | |
408 converted = buffer->GetAccessor(); | |
408 | 409 |
409 int64_t a, b; | 410 int64_t a, b; |
410 Orthanc::ImageProcessing::GetMinMaxValue(a, b, accessor); | 411 Orthanc::ImageProcessing::GetMinMaxValue(a, b, accessor); |
411 result["Orthanc"]["StretchLow"] = static_cast<int32_t>(a); | 412 result["Orthanc"]["StretchLow"] = static_cast<int32_t>(a); |
412 result["Orthanc"]["StretchHigh"] = static_cast<int32_t>(b); | 413 result["Orthanc"]["StretchHigh"] = static_cast<int32_t>(b); |