]> Creatis software - gdcm.git/blobdiff - src/gdcmPixelReadConvert.cxx
Swap64 deals with double (VR=FD)
[gdcm.git] / src / gdcmPixelReadConvert.cxx
index ef92293b33be090903346944856c377b5827f147..523201ce06ec5dbdea6054538819f22c1e56de8e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmPixelReadConvert.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/20 07:38:08 $
-  Version:   $Revision: 1.81 $
+  Date:      $Date: 2005/10/26 14:54:51 $
+  Version:   $Revision: 1.92 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -114,24 +114,37 @@ void PixelReadConvert::GrabInformationsFromFile( File *file )
    //PixelSize       = file->GetPixelSize();  Useless
    PixelSign       = file->IsSignedPixelData();
    SwapCode        = file->GetSwapCode();
-   std::string ts  = file->GetTransferSyntax();
-   IsRaw =
-        ( ! file->IsDicomV3() )
-     || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ImplicitVRLittleEndian
-     || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ImplicitVRBigEndianPrivateGE
-     || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ExplicitVRLittleEndian
-     || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ExplicitVRBigEndian
-     || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::DeflatedExplicitVRLittleEndian;
+   
+   if (! file->IsDicomV3() )  // Should be ACR-NEMA file
+   {
+      IsRaw = true;
+      // Don't loose time checking unexistant Transfer Syntax !
+      IsPrivateGETransferSyntax = IsMPEG
+             = IsJPEG2000 = IsJPEGLS = IsJPEGLossy  
+             = IsJPEGLossless = IsRLELossless 
+             = false;
+   }
+   else
+   {
+      std::string ts = file->GetTransferSyntax();
+
+      IsRaw =
+           Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ImplicitVRLittleEndian
+        || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ImplicitVRBigEndianPrivateGE
+        || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ExplicitVRLittleEndian
+        || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ExplicitVRBigEndian
+        || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::DeflatedExplicitVRLittleEndian;
      
-   IsPrivateGETransferSyntax = 
-                       ( Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ImplicitVRBigEndianPrivateGE );
-
-   IsMPEG          = Global::GetTS()->IsMPEG(ts);
-   IsJPEG2000      = Global::GetTS()->IsJPEG2000(ts);
-   IsJPEGLS        = Global::GetTS()->IsJPEGLS(ts);
-   IsJPEGLossy     = Global::GetTS()->IsJPEGLossy(ts);
-   IsJPEGLossless  = Global::GetTS()->IsJPEGLossless(ts);
-   IsRLELossless   = Global::GetTS()->IsRLELossless(ts);
+      IsPrivateGETransferSyntax = 
+                ( Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ImplicitVRBigEndianPrivateGE );
+
+      IsMPEG          = Global::GetTS()->IsMPEG(ts);
+      IsJPEG2000      = Global::GetTS()->IsJPEG2000(ts);
+      IsJPEGLS        = Global::GetTS()->IsJPEGLS(ts);
+      IsJPEGLossy     = Global::GetTS()->IsJPEGLossy(ts);
+      IsJPEGLossless  = Global::GetTS()->IsJPEGLossless(ts);
+      IsRLELossless   = Global::GetTS()->IsRLELossless(ts);
+   }
 
    PixelOffset     = file->GetPixelOffset();
    PixelDataLength = file->GetPixelAreaLength();
@@ -177,7 +190,7 @@ void PixelReadConvert::GrabInformationsFromFile( File *file )
       LutRedData = (uint8_t*)file->GetEntryBinArea( 0x0028, 0x1201 );
       if ( ! LutRedData )
       {
-         gdcmWarningMacro( "Unable to read Red Palette Color Lookup Table data" );
+         gdcmWarningMacro("Unable to read Red Palette Color Lookup Table data");
       }
 
       // //// Green round:
@@ -185,7 +198,7 @@ void PixelReadConvert::GrabInformationsFromFile( File *file )
       LutGreenData = (uint8_t*)file->GetEntryBinArea(0x0028, 0x1202 );
       if ( ! LutGreenData)
       {
-         gdcmWarningMacro( "Unable to read Green Palette Color Lookup Table data" );
+         gdcmWarningMacro("Unable to read Green Palette Color Lookup Table data");
       }
 
       // //// Blue round:
@@ -193,7 +206,7 @@ void PixelReadConvert::GrabInformationsFromFile( File *file )
       LutBlueData = (uint8_t*)file->GetEntryBinArea( 0x0028, 0x1203 );
       if ( ! LutBlueData )
       {
-         gdcmWarningMacro( "Unable to read Blue Palette Color Lookup Table data" );
+         gdcmWarningMacro("Unable to read Blue Palette Color Lookup Table data");
       }
    }
    FileInternal = file;   
@@ -241,7 +254,7 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp )
       if ( PixelDataLength != RawSize )
       {
          gdcmWarningMacro( "Mismatch between PixelReadConvert : "
-                            << PixelDataLength << " and RawSize : " << RawSize );
+                          << PixelDataLength << " and RawSize : " << RawSize );
       }
       if ( PixelDataLength > RawSize )
       {
@@ -260,7 +273,8 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp )
    } 
    else if ( IsRLELossless )
    {
-      if ( ! RLEInfo->DecompressRLEFile( fp, Raw, XSize, YSize, ZSize, BitsAllocated ) )
+      if ( ! RLEInfo->DecompressRLEFile
+                               ( fp, Raw, XSize, YSize, ZSize, BitsAllocated ) )
       {
          gdcmWarningMacro( "RLE decompressor failed." );
          return false;
@@ -525,17 +539,19 @@ bool PixelReadConvert::ReadAndDecompressJPEGFile( std::ifstream *fp )
 }
 
 /**
- * \brief Build Red/Green/Blue/Alpha LUT from File
- *         when (0028,0004),Photometric Interpretation = [PALETTE COLOR ]
- *          and (0028,1101),(0028,1102),(0028,1102)
- *            - xxx Palette Color Lookup Table Descriptor - are found
- *          and (0028,1201),(0028,1202),(0028,1202)
- *            - xxx Palette Color Lookup Table Data - are found
+ * \brief Build Red/Green/Blue/Alpha LUT from File when :
+ *         - (0028,0004) : Photometric Interpretation == [PALETTE COLOR ]
+ *         and
+ *         - (0028,1101),(0028,1102),(0028,1102)
+ *            xxx Palette Color Lookup Table Descriptor are found
+ *          and 
+ *         - (0028,1201),(0028,1202),(0028,1202)
+ *           xxx Palette Color Lookup Table Data - are found
  * \warning does NOT deal with :
- *   0028 1100 Gray Lookup Table Descriptor (Retired)
- *   0028 1221 Segmented Red Palette Color Lookup Table Data
- *   0028 1222 Segmented Green Palette Color Lookup Table Data
- *   0028 1223 Segmented Blue Palette Color Lookup Table Data
+ *   0028 1100 Gray Lookup Table Descriptor (Retired)
+ *   0028 1221 Segmented Red Palette Color Lookup Table Data
+ *   0028 1222 Segmented Green Palette Color Lookup Table Data
+ *   0028 1223 Segmented Blue Palette Color Lookup Table Data
  *   no known Dicom reader deals with them :-(
  * @return a RGBA Lookup Table
  */
@@ -771,7 +787,7 @@ void PixelReadConvert::ConvertSwapZone()
    // then the header is in little endian format and the pixel data is in 
    // big endian format.  When reading the header, GDCM has already established
    // a byte swapping code suitable for this machine to read the
-   // header. In TS::ImplicitVRLittleEndianDLXGE, this code will need
+   // header. In TS::ImplicitVRBigEndianPrivateGE, this code will need
    // to be switched in order to read the pixel data.  This must be
    // done REGARDLESS of the processor endianess!
    //
@@ -793,7 +809,9 @@ void PixelReadConvert::ConvertSwapZone()
    // Therefore, in either case, if the file is in
    // 'ImplicitVR BigEndian PrivateGE Transfer Syntax', then GDCM needs to switch
    // the byte swapping code when entering the pixel data.
-    
+
+/* //Let me check something.
+   //I wait for the Dashboard !   
    if ( IsPrivateGETransferSyntax )
    {
       // PrivateGETransferSyntax only exists for 'true' Dicom images
@@ -808,6 +826,7 @@ void PixelReadConvert::ConvertSwapZone()
             break;
       }  
    }
+*/   
    if ( BitsAllocated == 16 )
    {
       uint16_t *im16 = (uint16_t*)Raw;