comparison Plugin/DecodedImageAdapter.cpp @ 207:3d3d00e3e715

fix for new ImageAccessor API
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 08 Oct 2018 11:44:44 +0200
parents 993dd140bd30
children 2f27287c047c
comparison
equal deleted inserted replaced
206:d1ed9efdea6c 207:3d3d00e3e715
321 Orthanc::ImageAccessor converted; 321 Orthanc::ImageAccessor converted;
322 322
323 switch (accessor.GetFormat()) 323 switch (accessor.GetFormat())
324 { 324 {
325 case Orthanc::PixelFormat_RGB24: 325 case Orthanc::PixelFormat_RGB24:
326 converted = accessor; 326 accessor.GetReadOnlyAccessor(converted);
327 break; 327 break;
328 328
329 case Orthanc::PixelFormat_RGB48: 329 case Orthanc::PixelFormat_RGB48:
330 buffer.reset(new Orthanc::ImageBuffer(Orthanc::PixelFormat_RGB24, 330 buffer.reset(new Orthanc::ImageBuffer(Orthanc::PixelFormat_RGB24,
331 accessor.GetWidth(), 331 accessor.GetWidth(),
332 accessor.GetHeight(), false)); 332 accessor.GetHeight(), false));
333 converted = buffer->GetAccessor(); 333 buffer->GetWriteableAccessor(converted);
334 ConvertRGB48ToRGB24(converted, accessor); 334 ConvertRGB48ToRGB24(converted, accessor);
335 break; 335 break;
336 336
337 case Orthanc::PixelFormat_Grayscale8: 337 case Orthanc::PixelFormat_Grayscale8:
338 case Orthanc::PixelFormat_Grayscale16: 338 case Orthanc::PixelFormat_Grayscale16:
339 buffer.reset(new Orthanc::ImageBuffer(Orthanc::PixelFormat_Grayscale16, 339 buffer.reset(new Orthanc::ImageBuffer(Orthanc::PixelFormat_Grayscale16,
340 accessor.GetWidth(), 340 accessor.GetWidth(),
341 accessor.GetHeight(), 341 accessor.GetHeight(),
342 true /* force minimal pitch */)); 342 true /* force minimal pitch */));
343 converted = buffer->GetAccessor(); 343 buffer->GetWriteableAccessor(converted);
344 Orthanc::ImageProcessing::Convert(converted, accessor); 344 Orthanc::ImageProcessing::Convert(converted, accessor);
345 break; 345 break;
346 346
347 case Orthanc::PixelFormat_SignedGrayscale16: 347 case Orthanc::PixelFormat_SignedGrayscale16:
348 converted = accessor; 348 accessor.GetReadOnlyAccessor(converted);
349 break; 349 break;
350 350
351 default: 351 default:
352 // Unsupported pixel format 352 // Unsupported pixel format
353 return false; 353 return false;
432 432
433 if (accessor.GetFormat() == Orthanc::PixelFormat_Grayscale8 || 433 if (accessor.GetFormat() == Orthanc::PixelFormat_Grayscale8 ||
434 accessor.GetFormat() == Orthanc::PixelFormat_RGB24) 434 accessor.GetFormat() == Orthanc::PixelFormat_RGB24)
435 { 435 {
436 result["Orthanc"]["Stretched"] = false; 436 result["Orthanc"]["Stretched"] = false;
437 converted = accessor; 437 accessor.GetReadOnlyAccessor(converted);
438 } 438 }
439 else if (accessor.GetFormat() == Orthanc::PixelFormat_RGB48) 439 else if (accessor.GetFormat() == Orthanc::PixelFormat_RGB48)
440 { 440 {
441 result["Orthanc"]["Stretched"] = false; 441 result["Orthanc"]["Stretched"] = false;
442 442
443 buffer.reset(new Orthanc::ImageBuffer(Orthanc::PixelFormat_RGB24, 443 buffer.reset(new Orthanc::ImageBuffer(Orthanc::PixelFormat_RGB24,
444 accessor.GetWidth(), 444 accessor.GetWidth(),
445 accessor.GetHeight(), false)); 445 accessor.GetHeight(), false));
446 converted = buffer->GetAccessor(); 446 buffer->GetWriteableAccessor(converted);
447
447 ConvertRGB48ToRGB24(converted, accessor); 448 ConvertRGB48ToRGB24(converted, accessor);
448 } 449 }
449 else if (accessor.GetFormat() == Orthanc::PixelFormat_Grayscale16 || 450 else if (accessor.GetFormat() == Orthanc::PixelFormat_Grayscale16 ||
450 accessor.GetFormat() == Orthanc::PixelFormat_SignedGrayscale16) 451 accessor.GetFormat() == Orthanc::PixelFormat_SignedGrayscale16)
451 { 452 {
453 454
454 buffer.reset(new Orthanc::ImageBuffer(Orthanc::PixelFormat_Grayscale8, 455 buffer.reset(new Orthanc::ImageBuffer(Orthanc::PixelFormat_Grayscale8,
455 accessor.GetWidth(), 456 accessor.GetWidth(),
456 accessor.GetHeight(), 457 accessor.GetHeight(),
457 true /* force minimal pitch */)); 458 true /* force minimal pitch */));
458 converted = buffer->GetAccessor(); 459 buffer->GetWriteableAccessor(converted);
459 460
460 int64_t a, b; 461 int64_t a, b;
461 Orthanc::ImageProcessing::GetMinMaxIntegerValue(a, b, accessor); 462 Orthanc::ImageProcessing::GetMinMaxIntegerValue(a, b, accessor);
462 result["Orthanc"]["StretchLow"] = static_cast<int32_t>(a); 463 result["Orthanc"]["StretchLow"] = static_cast<int32_t>(a);
463 result["Orthanc"]["StretchHigh"] = static_cast<int32_t>(b); 464 result["Orthanc"]["StretchHigh"] = static_cast<int32_t>(b);