changeset 3811:890af7156f19 transcoding

fix transcoding to jpeg baseline
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Apr 2020 08:40:30 +0200
parents e9b7e05bcd42
children abd3a1d114c0
files Core/DicomParsing/FromDcmtkBridge.cpp
diffstat 1 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomParsing/FromDcmtkBridge.cpp	Mon Apr 06 12:36:49 2020 +0200
+++ b/Core/DicomParsing/FromDcmtkBridge.cpp	Tue Apr 07 08:40:30 2020 +0200
@@ -1257,8 +1257,8 @@
                                            DcmDataset& dataSet)
   {
     // Determine the transfer syntax which shall be used to write the
-    // information to the file. We always switch to the Little Endian
-    // syntax, with explicit length.
+    // information to the file. If not possible, switch to the Little
+    // Endian syntax, with explicit length.
 
     // http://support.dcmtk.org/docs/dcxfer_8h-source.html
 
@@ -1318,10 +1318,17 @@
       throw OrthancException(ErrorCode_InternalError);
     }
     else
-    {     
-      return (dicom.getDataset()->chooseRepresentation(xfer, representation).good() &&
-              dicom.getDataset()->canWriteXfer(xfer) &&
-              SaveToMemoryBufferInternal(buffer, dicom, xfer));
+    {
+      if (!dicom.getDataset()->chooseRepresentation(xfer, representation).good() ||
+          !dicom.getDataset()->canWriteXfer(xfer) ||
+          !dicom.validateMetaInfo(xfer, EWM_updateMeta).good())
+      {
+        return false;
+      }
+
+      dicom.removeInvalidGroups();
+      
+      return SaveToMemoryBufferInternal(buffer, dicom, xfer);
     }
   }