]> Creatis software - gdcm.git/blobdiff - src/gdcmPixelConvert.cxx
* Doc/Dicom2004_Part5.pdf added (thanks to JPR).
[gdcm.git] / src / gdcmPixelConvert.cxx
index e345dceaf92c0c3c539d807a0177ae548b13faf0..2afdb86c089c44217172bbf3344103314c46f655 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmPixelConvert.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/10/22 03:05:42 $
-  Version:   $Revision: 1.18 $
+  Date:      $Date: 2004/10/22 13:56:46 $
+  Version:   $Revision: 1.20 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -266,7 +266,7 @@ bool PixelConvert::ReadAndDecompressRLEFile( std::ifstream* fp )
       ++it )
    {
       // Loop on the fragments
-      for( int k = 1; k <= (*it)->NumberFragments; k++ )
+      for( unsigned int k = 1; k <= (*it)->NumberFragments; k++ )
       {
          //fseek( fp, (*it)->Offset[k] ,SEEK_SET );
          fp->seekg(  (*it)->Offset[k] , std::ios_base::beg );
@@ -613,7 +613,7 @@ bool PixelConvert::ReadAndDecompressPixelData( std::ifstream* fp )
    else if ( IsDecompressed )
    {
       fp->read( (char*)Decompressed, PixelDataLength);
-      if ( fp->fail() | |fp->eof())//Fp->gcount() == 1
+      if ( fp->fail() |fp->eof())//Fp->gcount() == 1
       {
          dbg.Verbose( 0, "PixelConvert::ReadAndDecompressPixelData: "
                          "reading of decompressed pixel data failed." );
@@ -783,15 +783,16 @@ void PixelConvert::GrabInformationsFromHeader( Header* header )
    PixelSize = header->GetPixelSize();
    PixelSign = header->IsSignedPixelData();
    SwapCode  = header->GetSwapCode();
+   TransferSyntaxType ts = header->GetTransferSyntax();
    IsDecompressed =
         ( ! header->IsDicomV3() )
-     || header->IsImplicitVRLittleEndianTransferSyntax()
-     || header->IsExplicitVRLittleEndianTransferSyntax()
-     || header->IsExplicitVRBigEndianTransferSyntax()
-     || header->IsDeflatedExplicitVRLittleEndianTransferSyntax();
+     || ts == ImplicitVRLittleEndian
+     || ts == ExplicitVRLittleEndian
+     || ts == ExplicitVRBigEndian
+     || ts == DeflatedExplicitVRLittleEndian;
    IsJPEG2000     = header->IsJPEG2000();
    IsJPEGLossless = header->IsJPEGLossless();
-   IsRLELossless  = header->IsRLELossLessTransferSyntax();
+   IsRLELossless  =  ( ts == RLELossless );
    PixelOffset     = header->GetPixelOffset();
    PixelDataLength = header->GetPixelAreaLength();
    RLEInfo  = header->GetRLEInfo();
@@ -1029,10 +1030,23 @@ void PixelConvert::BuildLUTRGBA()
  */
 bool PixelConvert::BuildRGBImage()
 {
+   if ( RGB )
+   {
+      // The job is allready done.
+      return true;
+   }
+
+   if ( ! Decompressed )
+   {
+      // The job can't be done
+      return false;
+   }
+
    BuildLUTRGBA();
-   if ( ( ! LutRGBA ) || ( ! Decompressed ) )
+   if ( ! LutRGBA )
    {
-       return false;
+      // The job can't be done
+      return false;
    }
                                                                                 
    // Build RGB Pixels
@@ -1040,7 +1054,7 @@ bool PixelConvert::BuildRGBImage()
    uint8_t* localRGB = RGB;
    for (size_t i = 0; i < DecompressedSize; ++i )
    {
-      int j  = Decompressed[i] * 4; // \todo I don't get this 4 coefficient !
+      int j  = Decompressed[i] * 4;
       *localRGB++ = LutRGBA[j];
       *localRGB++ = LutRGBA[j+1];
       *localRGB++ = LutRGBA[j+2];