Mercurial > hg > orthanc
changeset 5131:e107ff622e6d
merge
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 05 Jan 2023 17:25:21 +0100 |
parents | f2dcdbe05884 (current diff) 16138d6d568d (diff) |
children | 482f3e80ed0a |
files | NEWS |
diffstat | 2 files changed, 61 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Thu Jan 05 17:24:43 2023 +0100 +++ b/NEWS Thu Jan 05 17:25:21 2023 +0100 @@ -34,7 +34,12 @@ Common plugins code (C++) ------------------------- -* Added a 'header' argument to all OrthancPeers::DoPost, DoPut, ... +* Added a 'header' argument to all OrthancPeers::DoPost, DoPut, ... + +Maintenance +----------- + +* Fix decoding of RLE images for which the "Planar Configuration" tag (0028,0006) equals 1 version 1.11.2 (2022-08-30)
--- a/OrthancFramework/Sources/DicomParsing/Internals/DicomImageDecoder.cpp Thu Jan 05 17:24:43 2023 +0100 +++ b/OrthancFramework/Sources/DicomParsing/Internals/DicomImageDecoder.cpp Thu Jan 05 17:25:21 2023 +0100 @@ -644,6 +644,51 @@ } + static ImageAccessor* DecodePlanarConfiguration(const ImageAccessor& source) + { + /** + * This function will interleave the RGB channels, if the source + * DICOM image has the "Planar Configuration" (0028,0006) tag that + * equals 1. This process was not applied to images using the RLE + * codec, which led to the following issue: + * https://groups.google.com/g/orthanc-users/c/CSVWfRasSR0/m/y1XDRXVnAgAJ + **/ + + const unsigned int height = source.GetHeight(); + const unsigned int width = source.GetWidth(); + const size_t size = static_cast<size_t>(height) * static_cast<size_t>(width); + + if (source.GetFormat() != PixelFormat_RGB24 || + 3 * width != source.GetPitch()) + { + throw OrthancException(ErrorCode_NotImplemented); + } + + std::unique_ptr<ImageAccessor> target(new Image(PixelFormat_RGB24, width, height, false)); + + const uint8_t* red = reinterpret_cast<const uint8_t*>(source.GetConstBuffer()); + const uint8_t* green = red + size; + const uint8_t* blue = red + 2 * size; + + for (unsigned int y = 0; y < height; y++) + { + uint8_t* interleaved = reinterpret_cast<uint8_t*>(target->GetRow(y)); + for (unsigned int x = 0; x < width; x++) + { + interleaved[0] = *red; + interleaved[1] = *green; + interleaved[2] = *blue; + interleaved += 3; + red++; + green++; + blue++; + } + } + + return target.release(); + } + + ImageAccessor* DicomImageDecoder::ApplyCodec (const DcmCodec& codec, const DcmCodecParameter& parameters, @@ -700,7 +745,16 @@ "Cannot decode a non-palette image"); } - return target.release(); + if (target->GetFormat() == PixelFormat_RGB24 && + Orthanc::Toolbox::StripSpaces(decompressedColorModel.c_str()) == "RGB" && + info.IsPlanar()) + { + return DecodePlanarConfiguration(*target); + } + else + { + return target.release(); + } } }