X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmJPEGFragment.cxx;h=02b7a071aacbe522f85899291ed3b3d86978ca1b;hb=cf1a72a3dbc2c36edbc33b7ea1e638af53d4f250;hp=621134002588133871f51e8039581f1426c29c12;hpb=a19112da3ae4ddd5f5753b27390422af5cd05279;p=gdcm.git diff --git a/src/gdcmJPEGFragment.cxx b/src/gdcmJPEGFragment.cxx index 62113400..02b7a071 100644 --- a/src/gdcmJPEGFragment.cxx +++ b/src/gdcmJPEGFragment.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmJPEGFragment.cxx,v $ Language: C++ - Date: $Date: 2004/10/20 14:31:44 $ - Version: $Revision: 1.1 $ + Date: $Date: 2007/08/22 16:14:04 $ + Version: $Revision: 1.19 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -17,10 +17,21 @@ =========================================================================*/ #include "gdcmJPEGFragment.h" - -namespace gdcm +#include "gdcmDebug.h" + +namespace GDCM_NAME_SPACE { +//------------------------------------------------------------------------- +// For JPEG 2000, body in file gdcmJpeg2000.cxx +// Not yet made +bool gdcm_read_JPEG2000_file (std::ifstream *fp, void *image_buffer); +// For JPEG-LS, body in file gdcmJpegLS.cxx +// Not yet made +bool gdcm_read_JPEGLS_file (std::ifstream *fp, void *image_buffer); + +//------------------------------------------------------------------------- +// Constructor / Destructor /** * \brief Default constructor. */ @@ -28,14 +39,69 @@ JPEGFragment::JPEGFragment() { Offset = 0; Length = 0; + + pImage = 0; + +} + +//----------------------------------------------------------------------------- +// Public +/** + * \brief Decompress 8bits JPEG Fragment + * @param fp ifstream to write to + * @param buffer output (data decompress) + * @param nBits 8/12 or 16 bits jpeg + * @param statesuspension state suspension + */ +void JPEGFragment::DecompressJPEGFramesFromFile(std::ifstream *fp, + uint8_t *buffer, int nBits, + int &statesuspension) +{ + // First thing need to reset file to proper position: + fp->seekg( Offset, std::ios::beg); + + if ( nBits == 8 ) + { + // JPEG Lossy : call to IJG 6b - 8 bits + ReadJPEGFile8( fp, buffer, statesuspension); + } + else if ( nBits <= 12 ) + { + assert( nBits >= 8 ); + // JPEG Lossy : call to IJG 6b - 12 bits + ReadJPEGFile12 ( fp, buffer, statesuspension); + } + else if ( nBits <= 16 ) + { + assert( nBits >= 12 ); + // JPEG Lossy : call to IJG 6b - 16 bits + ReadJPEGFile16 ( fp, buffer, statesuspension); + //gdcmAssertMacro( IsJPEGLossless ); + } + else + { + // FIXME : only the bits number is checked, + // NOT the compression method + + // other JPEG lossy not supported + gdcmErrorMacro( "Unknown jpeg lossy compression "); + } } +//----------------------------------------------------------------------------- +// Protected + +//----------------------------------------------------------------------------- +// Private + +//----------------------------------------------------------------------------- +// Print /** * \brief Print self. - * @param indent Indentation string to be prepended during printing. * @param os Stream to print to. + * @param indent Indentation string to be prepended during printing. */ -void JPEGFragment::Print( std::string indent, std::ostream &os ) +void JPEGFragment::Print( std::ostream &os, std::string const &indent ) { os << indent << "JPEG fragment: offset : " << Offset @@ -43,5 +109,6 @@ void JPEGFragment::Print( std::string indent, std::ostream &os ) << std::endl; } +//----------------------------------------------------------------------------- } // end namespace gdcm