Mercurial > hg > orthanc-stone
comparison Framework/Loaders/SeriesThumbnailsLoader.cpp @ 1486:b931ddbe070e
preserve aspect ratio in SeriesThumbnailsLoader
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 23 Jun 2020 07:50:14 +0200 |
parents | 121d01aa328e |
children |
comparison
equal
deleted
inserted
replaced
1485:60be4627ae52 | 1486:b931ddbe070e |
---|---|
560 | 560 |
561 std::unique_ptr<Orthanc::ImageAccessor> thumbnail; | 561 std::unique_ptr<Orthanc::ImageAccessor> thumbnail; |
562 | 562 |
563 if (frame->GetFormat() == Orthanc::PixelFormat_RGB24) | 563 if (frame->GetFormat() == Orthanc::PixelFormat_RGB24) |
564 { | 564 { |
565 thumbnail.reset(Orthanc::ImageProcessing::FitSize(*frame, width_, height_)); | 565 thumbnail.reset(Orthanc::ImageProcessing::FitSizeKeepAspectRatio(*frame, width_, height_)); |
566 } | 566 } |
567 else | 567 else |
568 { | 568 { |
569 const unsigned int width = frame->GetWidth(); | |
570 const unsigned int height = frame->GetHeight(); | |
571 | |
572 std::unique_ptr<Orthanc::ImageAccessor> converted( | 569 std::unique_ptr<Orthanc::ImageAccessor> converted( |
573 new Orthanc::Image(Orthanc::PixelFormat_Float32, width, height, false)); | 570 new Orthanc::Image(Orthanc::PixelFormat_Float32, frame->GetWidth(), frame->GetHeight(), false)); |
574 Orthanc::ImageProcessing::Convert(*converted, *frame); | 571 Orthanc::ImageProcessing::Convert(*converted, *frame); |
575 | 572 |
576 std::unique_ptr<Orthanc::ImageAccessor> resized( | 573 std::unique_ptr<Orthanc::ImageAccessor> resized( |
577 Orthanc::ImageProcessing::FitSize(*converted, width, height)); | 574 Orthanc::ImageProcessing::FitSizeKeepAspectRatio(*converted, width_, height_)); |
578 | 575 |
579 float minValue, maxValue; | 576 float minValue, maxValue; |
580 Orthanc::ImageProcessing::GetMinMaxFloatValue(minValue, maxValue, *resized); | 577 Orthanc::ImageProcessing::GetMinMaxFloatValue(minValue, maxValue, *resized); |
581 if (minValue + 0.01f < maxValue) | 578 if (minValue + 0.01f < maxValue) |
582 { | 579 { |
587 Orthanc::ImageProcessing::Set(*resized, 0); | 584 Orthanc::ImageProcessing::Set(*resized, 0); |
588 } | 585 } |
589 | 586 |
590 converted.reset(NULL); | 587 converted.reset(NULL); |
591 | 588 |
592 thumbnail.reset(new Orthanc::Image(Orthanc::PixelFormat_Grayscale8, width, height, false)); | 589 thumbnail.reset(new Orthanc::Image(Orthanc::PixelFormat_Grayscale8, width_, height_, false)); |
593 Orthanc::ImageProcessing::Convert(*thumbnail, *resized); | 590 Orthanc::ImageProcessing::Convert(*thumbnail, *resized); |
594 } | 591 } |
595 | 592 |
596 std::string jpeg; | 593 std::string jpeg; |
597 Orthanc::JpegWriter writer; | 594 Orthanc::JpegWriter writer; |