]> Creatis software - gdcm.git/blobdiff - src/gdcmDocument.cxx
Add a comment about a patch to be able to reda wrong images, wher UN length is
[gdcm.git] / src / gdcmDocument.cxx
index 77af0cc52660ac0d3414266a3b662ade6daafe28..32e52d4a2a9bd472f19f8bd5ad807ca7c9d665db 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2007/06/18 11:10:17 $
-  Version:   $Revision: 1.361 $
+  Date:      $Date: 2007/07/11 12:21:01 $
+  Version:   $Revision: 1.363 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -1513,8 +1513,18 @@ void Document::FindDocEntryLength( DocEntry *entry )
    uint16_t length16;       
    if ( Filetype == ExplicitVR && !entry->IsImplicitVR() ) 
    {
+   
+   // WARNING :
+   //
+   // For some images, length of UN elements is coded on 2 bytes (instead of 4)
+   // There are *not* readable !
+   // You can make a quick and dirty patch, commenting out 
+   //| vr == "UN"
+   // in the following line.
+   // (the 'straight' images will no longer be readable ...)
+   
       if ( vr == "OB" || vr == "OW" || vr == "SQ" || vr == "UT" 
-                                                           || vr == "UN" || changeFromUN == true)
+                                                          || vr == "UN" || changeFromUN == true)
       {
          changeFromUN = false;
          // The following reserved two bytes (see PS 3.5-2003, section
@@ -2103,26 +2113,18 @@ bool Document::CheckSwap()
                    return false;
                s16 = *((uint16_t *)(deb+2));
 
-               //s32 = *((uint32_t *)(deb));
                Fp->seekg ( 0L, std::ios::beg); // Once per Document
                CurrentOffsetPosition = 0;
                switch(s16)  // try an other trick!
                             // -> to be able to decode 0029|1010 DataElement
                             // -> and be not less cleaver than dcmdump ;-)
                {
-                  case 0x00040000 :
-                     SwapCode = 4321;
+                  case 0x0004 :
+                     SwapCode = 1234; 
                      break;
-                  case 0x04000000 :
+                  case 0x0400 :
                      SwapCode = 3412;
-                     break;
-                  case 0x00000400 :
-                     SwapCode = 2143;
-                     break;
-                  case 0x00000004 :
-                     SwapCode = 1234;
-                      break;
-     
+                     break;      
                   default:
                      gdcmWarningMacro("ACR/NEMA unfound swap info (Hopeless !)");
                      Filetype = Unknown;