00001 /*========================================================================= 00002 00003 Program: gdcm 00004 Module: $RCSfile: gdcmJPEGFragment.cxx,v $ 00005 Language: C++ 00006 Date: $Date: 2005/11/28 17:24:21 $ 00007 Version: $Revision: 1.17 $ 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 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 // JPEG Lossy : call to IJG 6b - 12 bits 00071 ReadJPEGFile12 ( fp, buffer, statesuspension); 00072 } 00073 else if ( nBits <= 16 ) 00074 { 00075 // JPEG Lossy : call to IJG 6b - 16 bits 00076 ReadJPEGFile16 ( fp, buffer, statesuspension); 00077 //gdcmAssertMacro( IsJPEGLossless ); 00078 } 00079 else 00080 { 00081 // FIXME : only the bits number is checked, 00082 // NOT the compression method 00083 00084 // other JPEG lossy not supported 00085 gdcmErrorMacro( "Unknown jpeg lossy compression "); 00086 } 00087 } 00088 00089 //----------------------------------------------------------------------------- 00090 // Protected 00091 00092 //----------------------------------------------------------------------------- 00093 // Private 00094 00095 //----------------------------------------------------------------------------- 00096 // Print 00102 void JPEGFragment::Print( std::ostream &os, std::string const &indent ) 00103 { 00104 os << indent 00105 << "JPEG fragment: offset : " << Offset 00106 << " length : " << Length 00107 << std::endl; 00108 } 00109 00110 //----------------------------------------------------------------------------- 00111 } // end namespace gdcm 00112