]> Creatis software - gdcm.git/blobdiff - src/gdcmPixelReadConvert.cxx
ENH: Adding initial implementation for jasper/jpeg2000 support
[gdcm.git] / src / gdcmPixelReadConvert.cxx
index 2970f1f01e73b5b3a57493f00659e6a54f808660..38955fe7b2438ef2f2df9635ff42847c973e0879 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmPixelReadConvert.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/03/31 09:46:51 $
-  Version:   $Revision: 1.54 $
+  Date:      $Date: 2005/05/22 18:38:52 $
+  Version:   $Revision: 1.57 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -30,6 +30,9 @@
 
 namespace gdcm
 {
+
+bool ReadMPEGFile (std::ifstream *fp, void *image_buffer);
+bool gdcm_read_JPEG2000_file (std::ifstream* fp, void* raw, size_t inputlength);
 //-----------------------------------------------------------------------------
 #define str2num(str, typeNum) *((typeNum *)(str))
 
@@ -115,6 +118,7 @@ void PixelReadConvert::GrabInformationsFromFile( File *file )
      || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::ExplicitVRBigEndian
      || Global::GetTS()->GetSpecialTransferSyntax(ts) == TS::DeflatedExplicitVRLittleEndian;
 
+   IsMPEG          = Global::GetTS()->IsMPEG(ts);
    IsJPEG2000      = Global::GetTS()->IsJPEG2000(ts);
    IsJPEGLS        = Global::GetTS()->IsJPEGLS(ts);
    IsJPEGLossy     = Global::GetTS()->IsJPEGLossy(ts);
@@ -250,6 +254,13 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp )
          return false;
       }
    }
+   else if ( IsMPEG )
+   {
+      //gdcmWarningMacro( "Sorry, MPEG not yet taken into account" );
+      //return false;
+      ReadMPEGFile(fp, Raw); // fp has already been seek to start of mpeg
+      return true;
+   }
    else
    {
       // Default case concerns JPEG family
@@ -386,9 +397,9 @@ bool PixelReadConvert::ReadAndDecompressJPEGFile( std::ifstream *fp )
 {
    if ( IsJPEG2000 )
    {
-      gdcmWarningMacro( "Sorry, JPEG2000 not yet taken into account" );
+//      gdcmWarningMacro( "Sorry, JPEG2000 not yet taken into account" );
       fp->seekg( JPEGInfo->GetFirstFragment()->GetOffset(), std::ios::beg);
-//    if ( ! gdcm_read_JPEG2000_file( fp,Raw ) )
+    if ( ! gdcm_read_JPEG2000_file( fp,Raw, JPEGInfo->GetFirstFragment()->GetLength() ) )
           return false;
    }