X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmPixelReadConvert.cxx;h=66d41820237be7a95129a27023d397562e14ffb4;hb=f2892379e89dd5236abb60ea3c84c3fe9d5ef45f;hp=66bcbfdeaad67b93616528281824a9b9730fbe7a;hpb=9b08ef2e93023e33dad3326a0c7d6b5db7b72cd4;p=gdcm.git diff --git a/src/gdcmPixelReadConvert.cxx b/src/gdcmPixelReadConvert.cxx index 66bcbfde..66d41820 100644 --- a/src/gdcmPixelReadConvert.cxx +++ b/src/gdcmPixelReadConvert.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmPixelReadConvert.cxx,v $ Language: C++ - Date: $Date: 2005/05/21 18:43:53 $ - Version: $Revision: 1.56 $ + Date: $Date: 2005/05/30 00:24:10 $ + Version: $Revision: 1.62 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -31,7 +31,8 @@ namespace gdcm { -extern bool ReadMPEGFile (std::ifstream *fp, void *image_buffer); +//bool ReadMPEGFile (std::ifstream *fp, void *image_buffer, size_t lenght); +bool gdcm_read_JPEG2000_file (std::ifstream* fp, void* raw, size_t inputlength); //----------------------------------------------------------------------------- #define str2num(str, typeNum) *((typeNum *)(str)) @@ -257,7 +258,7 @@ bool PixelReadConvert::ReadAndDecompressPixelData( std::ifstream *fp ) { //gdcmWarningMacro( "Sorry, MPEG not yet taken into account" ); //return false; - ReadMPEGFile(fp, Raw); // fp has already been seek to start of mpeg +// ReadMPEGFile(fp, Raw, PixelDataLength); // fp has already been seek to start of mpeg return true; } else @@ -396,27 +397,41 @@ bool PixelReadConvert::ReadAndDecompressJPEGFile( std::ifstream *fp ) { if ( IsJPEG2000 ) { - gdcmWarningMacro( "Sorry, JPEG2000 not yet taken into account" ); + // I don't think we'll ever be able to deal with multiple fragments + assert( JPEGInfo->GetFragmentCount() == 1 ); fp->seekg( JPEGInfo->GetFirstFragment()->GetOffset(), std::ios::beg); -// if ( ! gdcm_read_JPEG2000_file( fp,Raw ) ) - return false; + if ( ! gdcm_read_JPEG2000_file( fp,Raw, + JPEGInfo->GetFirstFragment()->GetLength() ) ) + { + return true; + } } if ( IsJPEGLS ) { + // WARNING : JPEG-LS is NOT the 'classical' Jpeg Lossless : + // [JPEG-LS is the basis for new lossless/near-lossless compression + // standard for continuous-tone images intended for JPEG2000. The standard + // is based on the LOCO-I algorithm (LOw COmplexity LOssless COmpression + // for Images) developed at Hewlett-Packard Laboratories] + // + // see http://datacompression.info/JPEGLS.shtml + // + gdcmWarningMacro( "Sorry, JPEG-LS not yet taken into account" ); fp->seekg( JPEGInfo->GetFirstFragment()->GetOffset(), std::ios::beg); // if ( ! gdcm_read_JPEGLS_file( fp,Raw ) ) return false; } - - // else ?? - // Precompute the offset localRaw will be shifted with - int length = XSize * YSize * SamplesPerPixel; - int numberBytes = BitsAllocated / 8; - - JPEGInfo->DecompressFromFile(fp, Raw, BitsStored, numberBytes, length ); - return true; + else + { + // Precompute the offset localRaw will be shifted with + int length = XSize * YSize * SamplesPerPixel; + int numberBytes = BitsAllocated / 8; + + JPEGInfo->DecompressFromFile(fp, Raw, BitsStored, numberBytes, length ); + return true; + } } /**