]> Creatis software - gdcm.git/blob - src/gdcmJPEGFragment.h
e6d74eb8d408fc8954c890a3a2a7da4fe438d8f5
[gdcm.git] / src / gdcmJPEGFragment.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmJPEGFragment.h,v $
5   Language:  C++
6   Date:      $Date: 2005/01/31 04:00:04 $
7   Version:   $Revision: 1.15 $
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 #include <fstream>
27
28 namespace gdcm 
29 {
30 /**
31  * \brief Utility class for summerizing the informations of a JPEG
32  *        fragment of an "Encapsulated JPEG Compressed Image".
33  *        This information is a mix of:
34  *        - the fragment offset
35  *        - the fragment length 
36  *
37  *        Each instance of this class (they can be as many instances for
38  *        a given Document as they are JPEG fragments and they are
39  *        collected in a \ref JPEGFragmentsInfo )
40  */
41 class GDCM_EXPORT JPEGFragment
42 {
43 public:
44    JPEGFragment();
45    void Print( std::ostream &os = std::cout, std::string indent = "" );
46    void DecompressJPEGFramesFromFile(std::ifstream *fp, uint8_t *buffer, int nBits, int & statesuspension);
47
48    bool ReadJPEGFile8 (std::ifstream* fp, void* image_buffer, int & statesuspension );
49    bool ReadJPEGFile12 (std::ifstream* fp, void* image_buffer, int & statesuspension );
50    bool ReadJPEGFile16 (std::ifstream* fp, void* image_buffer, int & statesuspension );
51
52    void SetLength(uint32_t length) { Length = length; };
53    uint32_t GetLength() { return Length;};
54    void SetOffset(uint32_t offset) { Offset = offset; };
55    uint32_t GetOffset() { return Offset;};
56    uint8_t *GetImage()  { return pImage;};
57
58 private:
59    uint32_t Offset;
60    uint32_t Length;
61
62    uint8_t *pImage;
63 };
64 } // end namespace gdcm
65
66 //-----------------------------------------------------------------------------
67 #endif