]> Creatis software - gdcm.git/commitdiff
To avoid pb with xmedcon-breaker CT McTwin Elscint images
authorjpr <jpr>
Mon, 27 Oct 2003 16:45:57 +0000 (16:45 +0000)
committerjpr <jpr>
Mon, 27 Oct 2003 16:45:57 +0000 (16:45 +0000)
src/gdcmFile.cxx

index ed51d6984503b8d15e0ef21f7e77c3abd586d808..5952e63ba962e6e4e065f871cf965b132eedc1c8 100644 (file)
@@ -161,8 +161,8 @@ bool gdcmFile::ReadPixelData(void* destination) {
         IsImplicitVRLittleEndianTransferSyntax() ||
         IsExplicitVRLittleEndianTransferSyntax() ||
         IsExplicitVRBigEndianTransferSyntax()    ||
-        IsDeflatedExplicitVRLittleEndianTransferSyntax() ) { 
-                    
+        IsDeflatedExplicitVRLittleEndianTransferSyntax() ) {
+               
       size_t ItemRead = fread(destination, lgrTotale, 1, fp);
       if ( ItemRead != 1 ) {
          CloseFile();
@@ -354,9 +354,11 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t MaxSize) {
    }
                
        // Signe des Pixels 
+       // 0 = Unsigned
+       // 1 = Signed
    str_signe=GetPubElValByNumber(0x0028,0x0103);
    if (str_signe == GDCM_UNFOUND ) {
-      signe = 1;
+      signe = 0;  // default is unsigned
    } else {
       signe = atoi(str_signe.c_str() );
    }
@@ -364,7 +366,18 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t MaxSize) {
    // re arange bytes inside the integer
    if (nb != 8)
      SwapZone(destination, GetSwapCode(), lgrTotale, nb);
+     
+   // to avoid pb with some xmedcon breakers images 
+   if (nb==16 && nbu<nb && signe==0) {
+     int l = (int)lgrTotale / (nb/8);
+     guint16 *deb = (guint16 *)destination;
+     for(int i = 0; i<l; i++) {
+        if(*deb == 0xffff) 
+          *deb=0; 
+          deb++;   
+         }
+    }
+
    // re arange bits inside the bytes
    if (nbu != nb){
       int l = (int)lgrTotale / (nb/8);
@@ -390,6 +403,7 @@ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t MaxSize) {
       }
    } 
 
+
 // Just to 'see' was was actually read on disk :-(
 // Some troubles expected