Mercurial > hg > orthanc
diff 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 |
line wrap: on
line diff
--- a/OrthancServer/Internals/DicomImageDecoder.cpp Thu Jul 10 11:13:26 2014 +0200 +++ b/OrthancServer/Internals/DicomImageDecoder.cpp Thu Jul 10 11:24:25 2014 +0200 @@ -589,10 +589,18 @@ } + static bool IsColorImage(PixelFormat format) + { + return (format == PixelFormat_RGB24 || + format == PixelFormat_RGBA32); + } + + bool DicomImageDecoder::DecodeAndTruncate(ImageBuffer& target, DcmDataset& dataset, unsigned int frame, - PixelFormat format) + PixelFormat format, + bool allowColorConversion) { // TODO Special case for uncompressed images @@ -602,6 +610,19 @@ return false; } + // If specified, prevent the conversion between color and + // grayscale images + bool isSourceColor = IsColorImage(source.GetFormat()); + bool isTargetColor = IsColorImage(format); + + if (!allowColorConversion) + { + if (isSourceColor ^ isTargetColor) + { + return false; + } + } + if (source.GetFormat() == format) { // No conversion is required, return the temporary image