Mercurial > hg > orthanc
changeset 1016:f4bbf13572cd
integration plugins->mainline
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 10 Jul 2014 11:26:05 +0200 |
parents | f009f7c75069 (diff) 79e720ca043e (current diff) |
children | 564e39d6df13 1fc112c4b832 |
files | |
diffstat | 3 files changed, 27 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/Internals/DicomImageDecoder.cpp Thu Jul 10 11:25:32 2014 +0200 +++ b/OrthancServer/Internals/DicomImageDecoder.cpp Thu Jul 10 11:26:05 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
--- a/OrthancServer/Internals/DicomImageDecoder.h Thu Jul 10 11:25:32 2014 +0200 +++ b/OrthancServer/Internals/DicomImageDecoder.h Thu Jul 10 11:26:05 2014 +0200 @@ -72,7 +72,8 @@ static bool DecodeAndTruncate(ImageBuffer& target, DcmDataset& dataset, unsigned int frame, - PixelFormat format); + PixelFormat format, + bool allowColorConversion); static bool DecodePreview(ImageBuffer& target, DcmDataset& dataset,
--- a/OrthancServer/ParsedDicomFile.cpp Thu Jul 10 11:25:32 2014 +0200 +++ b/OrthancServer/ParsedDicomFile.cpp Thu Jul 10 11:26:05 2014 +0200 @@ -1172,15 +1172,15 @@ switch (mode) { case ImageExtractionMode_UInt8: - ok = DicomImageDecoder::DecodeAndTruncate(result, dataset, frame, PixelFormat_Grayscale8); + ok = DicomImageDecoder::DecodeAndTruncate(result, dataset, frame, PixelFormat_Grayscale8, false); break; case ImageExtractionMode_UInt16: - ok = DicomImageDecoder::DecodeAndTruncate(result, dataset, frame, PixelFormat_Grayscale16); + ok = DicomImageDecoder::DecodeAndTruncate(result, dataset, frame, PixelFormat_Grayscale16, false); break; case ImageExtractionMode_Int16: - ok = DicomImageDecoder::DecodeAndTruncate(result, dataset, frame, PixelFormat_SignedGrayscale16); + ok = DicomImageDecoder::DecodeAndTruncate(result, dataset, frame, PixelFormat_SignedGrayscale16, false); break; case ImageExtractionMode_Preview: