diff OrthancFramework/Sources/DicomParsing/Internals/DicomImageDecoder.cpp @ 5283:57c0fba5e5c7

fix decoding of YBR_FULL RLE images with PlanarConfiguration=1
author Alain Mazy <am@osimis.io>
date Fri, 21 Apr 2023 10:35:07 +0200
parents 0ea402b4d901
children 48b8dae6dc77
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomParsing/Internals/DicomImageDecoder.cpp	Mon Apr 17 08:56:43 2023 +0200
+++ b/OrthancFramework/Sources/DicomParsing/Internals/DicomImageDecoder.cpp	Fri Apr 21 10:35:07 2023 +0200
@@ -745,11 +745,20 @@
                                "Cannot decode a non-palette image");
       }
 
+      std::string colorModel = Orthanc::Toolbox::StripSpaces(decompressedColorModel.c_str());
+
       if (target->GetFormat() == PixelFormat_RGB24 &&
-          Orthanc::Toolbox::StripSpaces(decompressedColorModel.c_str()) == "RGB" &&
+          (colorModel == "RGB" || colorModel == "YBR_FULL") &&
           info.IsPlanar())
       {
-        return DecodePlanarConfiguration(*target);
+        std::unique_ptr<ImageAccessor> output(DecodePlanarConfiguration(*target));
+
+        if (colorModel == "YBR_FULL")
+        {
+          ImageProcessing::ConvertJpegYCbCrToRgb(*output);
+        }
+
+        return output.release();
       }
       else
       {