comparison OrthancServer/Internals/DicomImageDecoder.cpp @ 1015:f009f7c75069

fix integration tests
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 10 Jul 2014 11:24:25 +0200
parents b3f6fb1130cd
children 851a55d183c9
comparison
equal deleted inserted replaced
1014:40e5255e7dc5 1015:f009f7c75069
587 587
588 return false; 588 return false;
589 } 589 }
590 590
591 591
592 static bool IsColorImage(PixelFormat format)
593 {
594 return (format == PixelFormat_RGB24 ||
595 format == PixelFormat_RGBA32);
596 }
597
598
592 bool DicomImageDecoder::DecodeAndTruncate(ImageBuffer& target, 599 bool DicomImageDecoder::DecodeAndTruncate(ImageBuffer& target,
593 DcmDataset& dataset, 600 DcmDataset& dataset,
594 unsigned int frame, 601 unsigned int frame,
595 PixelFormat format) 602 PixelFormat format,
603 bool allowColorConversion)
596 { 604 {
597 // TODO Special case for uncompressed images 605 // TODO Special case for uncompressed images
598 606
599 ImageBuffer source; 607 ImageBuffer source;
600 if (!Decode(source, dataset, frame)) 608 if (!Decode(source, dataset, frame))
601 { 609 {
602 return false; 610 return false;
611 }
612
613 // If specified, prevent the conversion between color and
614 // grayscale images
615 bool isSourceColor = IsColorImage(source.GetFormat());
616 bool isTargetColor = IsColorImage(format);
617
618 if (!allowColorConversion)
619 {
620 if (isSourceColor ^ isTargetColor)
621 {
622 return false;
623 }
603 } 624 }
604 625
605 if (source.GetFormat() == format) 626 if (source.GetFormat() == format)
606 { 627 {
607 // No conversion is required, return the temporary image 628 // No conversion is required, return the temporary image