]> Creatis software - gdcm.git/blob - src/gdcmJPEGFragment.h
ENH: First pass at simplifying the JPEG stuff.
[gdcm.git] / src / gdcmJPEGFragment.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmJPEGFragment.h,v $
5   Language:  C++
6   Date:      $Date: 2005/01/17 01:14:33 $
7   Version:   $Revision: 1.8 $
8                                                                                 
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.
12                                                                                 
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.
16                                                                                 
17 =========================================================================*/
18
19
20 #ifndef GDCMJPEGFRAGMENT_H
21 #define GDCMJPEGFRAGMENT_H
22
23 #include "gdcmCommon.h"
24
25 #include <iostream>
26
27 namespace gdcm 
28 {
29 #define JOCTET uint8_t
30
31 /**
32  * \brief Utility class for summerizing the informations of a JPEG
33  *        fragment of an "Encapsulated JPEG Compressed Image".
34  *        This information is a mix of:
35  *        - the fragment offset
36  *        - the fragment length 
37  *
38  *        Each instance of this class (they can be as many instances for
39  *        a given Document as they are JPEG fragments and they are
40  *        collected in a \ref JPEGFragmentsInfo )
41  */
42 class GDCM_EXPORT JPEGFragment
43 {
44 public:
45    JPEGFragment();
46    void Print( std::ostream &os = std::cout, std::string indent = "" );
47    void DecompressJPEGFramesFromFile(std::ifstream *fp, uint8_t *buffer, int nBits);
48    void DecompressJPEGSingleFrameFragmentsFromFile(JOCTET *buffer, size_t totalLength, uint8_t* raw, int nBits);
49    void DecompressJPEGFragmentedFramesFromFile(JOCTET *buffer, uint8_t* raw, int nBits, size_t &howManyRead, size_t &howManyWritten, size_t totalLength);
50
51 private:
52    long    Offset;
53    long    Length;
54
55 friend class Document;
56 friend class File;
57 friend class PixelReadConvert;
58 };
59 } // end namespace gdcm
60
61 //-----------------------------------------------------------------------------
62 #endif