1 /*=========================================================================
4 Module: $RCSfile: gdcmJPEGFragment.cxx,v $
6 Date: $Date: 2005/02/04 16:51:36 $
7 Version: $Revision: 1.14 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
19 #include "gdcmJPEGFragment.h"
20 #include "gdcmDebug.h"
24 //-------------------------------------------------------------------------
25 // For JPEG 2000, body in file gdcmJpeg2000.cxx
27 bool gdcm_read_JPEG2000_file (std::ifstream *fp, void *image_buffer);
29 // For JPEG-LS, body in file gdcmJpegLS.cxx
31 bool gdcm_read_JPEGLS_file (std::ifstream *fp, void *image_buffer);
33 //-------------------------------------------------------------------------
34 // Constructor / Destructor
36 * \brief Default constructor.
38 JPEGFragment::JPEGFragment()
47 //-----------------------------------------------------------------------------
50 * \brief Decompress 8bits JPEG Fragment
51 * @param fp ifstream to write to
52 * @param buffer output (data decompress)
53 * @param nBits 8/12 or 16 bits jpeg
54 * @param statesuspension state suspension
56 void JPEGFragment::DecompressJPEGFramesFromFile(std::ifstream *fp,
57 uint8_t *buffer, int nBits,
60 // First thing need to reset file to proper position:
61 fp->seekg( Offset, std::ios::beg);
65 // JPEG Lossy : call to IJG 6b - 8 bits
66 ReadJPEGFile8( fp, buffer, statesuspension);
68 else if ( nBits <= 12 )
70 // JPEG Lossy : call to IJG 6b - 12 bits
71 ReadJPEGFile12 ( fp, buffer, statesuspension);
73 else if ( nBits <= 16 )
75 // JPEG Lossy : call to IJG 6b - 16 bits
76 ReadJPEGFile16 ( fp, buffer, statesuspension);
77 //gdcmAssertMacro( IsJPEGLossless );
81 // FIXME : only the bits number is checked,
82 // NOT the compression method
84 // other JPEG lossy not supported
85 gdcmErrorMacro( "Unknown jpeg lossy compression ");
89 //-----------------------------------------------------------------------------
92 //-----------------------------------------------------------------------------
95 //-----------------------------------------------------------------------------
99 * @param os Stream to print to.
100 * @param indent Indentation string to be prepended during printing.
102 void JPEGFragment::Print( std::ostream &os, std::string indent )
105 << "JPEG fragment: offset : " << Offset
106 << " length : " << Length
110 //-----------------------------------------------------------------------------
111 } // end namespace gdcm