changeset 52:ff8aec4536de

Prevent transcoding of 1-bit images
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 05 Jul 2021 08:33:21 +0200
parents 79b03e3437bd
children 1668af19f8ef
files NEWS Plugin/Plugin.cpp
diffstat 2 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Wed Jun 23 09:07:46 2021 +0200
+++ b/NEWS	Mon Jul 05 08:33:21 2021 +0200
@@ -1,6 +1,8 @@
 Pending changes in the mainline
 ===============================
 
+* Prevent transcoding of 1-bit images
+
 
 Version 1.3 (2021-06-14)
 ========================
--- a/Plugin/Plugin.cpp	Wed Jun 23 09:07:46 2021 +0200
+++ b/Plugin/Plugin.cpp	Mon Jul 05 08:33:21 2021 +0200
@@ -340,6 +340,13 @@
       gdcm::TransferSyntax syntax(gdcm::TransferSyntax::GetTSType(allowedSyntaxes[i]));
       if (syntax.IsValid())
       {
+        if (reader.GetImage().GetPixelFormat().GetBitsAllocated() == 1u)
+        {
+          // Prevent transcoding of 1-bit images, as this might crash GDCM
+          // https://groups.google.com/g/orthanc-users/c/xIwrkFRceuE/m/jwxy50djAQAJ
+          throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented, "Cannot transcode 1bit images");
+        }
+        
         if (reader.GetImage().GetPixelFormat().GetBitsStored() == 16u &&
             syntax == gdcm::TransferSyntax::JPEGExtendedProcess2_4)
         {