gdcmJPEGFragment.cxx

Go to the documentation of this file.
00001 /*=========================================================================
00002                                                                                 
00003   Program:   gdcm
00004   Module:    $RCSfile: gdcmJPEGFragment.cxx,v $
00005   Language:  C++
00006   Date:      $Date: 2007/08/22 16:14:04 $
00007   Version:   $Revision: 1.19 $
00008                                                                                 
00009   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
00010   l'Image). All rights reserved. See Doc/License.txt or
00011   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
00012                                                                                 
00013      This software is distributed WITHOUT ANY WARRANTY; without even
00014      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00015      PURPOSE.  See the above copyright notices for more information.
00016                                                                                 
00017 =========================================================================*/
00018                                                                                 
00019 #include "gdcmJPEGFragment.h"
00020 #include "gdcmDebug.h"
00021 
00022 namespace GDCM_NAME_SPACE
00023 {
00024 //-------------------------------------------------------------------------
00025 // For JPEG 2000, body in file gdcmJpeg2000.cxx
00026 // Not yet made
00027 bool gdcm_read_JPEG2000_file (std::ifstream *fp, void *image_buffer);
00028 
00029 // For JPEG-LS, body in file gdcmJpegLS.cxx
00030 // Not yet made
00031 bool gdcm_read_JPEGLS_file (std::ifstream *fp, void *image_buffer);
00032 
00033 //-------------------------------------------------------------------------
00034 // Constructor / Destructor
00038 JPEGFragment::JPEGFragment()
00039 {
00040    Offset = 0;
00041    Length = 0;
00042 
00043    pImage = 0;
00044 
00045 }
00046 
00047 //-----------------------------------------------------------------------------
00048 // Public
00056 void JPEGFragment::DecompressJPEGFramesFromFile(std::ifstream *fp,
00057                                                 uint8_t *buffer, int nBits, 
00058                                                 int &statesuspension)
00059 {
00060    // First thing need to reset file to proper position:
00061    fp->seekg( Offset, std::ios::beg);
00062 
00063    if ( nBits == 8 )
00064    {
00065       // JPEG Lossy : call to IJG 6b - 8 bits
00066       ReadJPEGFile8( fp, buffer, statesuspension);
00067    }
00068    else if ( nBits <= 12 )
00069    {
00070        assert( nBits >= 8 );
00071       // JPEG Lossy : call to IJG 6b - 12 bits
00072       ReadJPEGFile12 ( fp, buffer, statesuspension);
00073    }
00074    else if ( nBits <= 16 )
00075    {
00076        assert( nBits >= 12 );
00077       // JPEG Lossy : call to IJG 6b - 16 bits
00078       ReadJPEGFile16 ( fp, buffer, statesuspension);
00079       //gdcmAssertMacro( IsJPEGLossless );
00080    }
00081    else
00082    {
00083       // FIXME : only the bits number is checked,
00084       //         NOT the compression method
00085 
00086       // other JPEG lossy not supported
00087       gdcmErrorMacro( "Unknown jpeg lossy compression ");
00088    }
00089 }
00090 
00091 //-----------------------------------------------------------------------------
00092 // Protected
00093 
00094 //-----------------------------------------------------------------------------
00095 // Private
00096 
00097 //-----------------------------------------------------------------------------
00098 // Print
00104 void JPEGFragment::Print( std::ostream &os, std::string const &indent )
00105 {
00106    os << indent
00107       << "JPEG fragment: offset : " <<  Offset
00108       << "   length : " <<  Length
00109       << std::endl;
00110 }
00111 
00112 //-----------------------------------------------------------------------------
00113 } // end namespace gdcm
00114 

Generated on Fri Aug 24 12:59:31 2007 for gdcm by  doxygen 1.4.6