]> Creatis software - gdcm.git/blob - src/gdcmPixelReadConvert.h
* Reorder source code (last one, I hope)
[gdcm.git] / src / gdcmPixelReadConvert.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmPixelReadConvert.h,v $
5   Language:  C++
6   Date:      $Date: 2005/02/02 16:34:55 $
7   Version:   $Revision: 1.17 $
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 GDCMPIXELREADCONVERT_H
21 #define GDCMPIXELREADCONVERT_H
22
23 #include "gdcmCommon.h"
24 #include "gdcmBase.h"
25 #include "gdcmException.h"
26
27 namespace gdcm
28 {
29 class File;
30 class RLEFramesInfo;
31 class JPEGFragmentsInfo;
32
33 /**
34  * \brief Utility container for gathering the various forms the pixel data
35  *        migth take during the user demanded processes.
36  */
37 class GDCM_EXPORT PixelReadConvert : public Base
38 {
39 public:
40    PixelReadConvert();
41    virtual ~PixelReadConvert();
42
43    void Print( std::ostream &os = std::cout, std::string const & indent = "" );
44
45    // Getter accessors:
46    uint8_t* GetRGB()     { return RGB; }
47    size_t   GetRGBSize() { return RGBSize; }
48    uint8_t* GetRaw()     { return Raw; }
49    size_t   GetRawSize() { return RawSize; }
50    uint8_t* GetLutRGBA() { return LutRGBA; }
51
52    // Predicates:
53    bool IsRawRGB();
54
55 // In progress
56    void GrabInformationsFromFile( File *file );
57    bool ReadAndDecompressPixelData( std::ifstream *fp );
58    void Squeeze();
59    bool BuildRGBImage();
60
61 private:
62    // Use the fp:
63    void ReadAndDecompress12BitsTo16Bits( std::ifstream *fp ) throw ( FormatError );
64    bool ReadAndDecompressJPEGFile( std::ifstream *fp );
65
66    // In place (within Decompressed and with no fp access) decompression
67    // or convertion:
68    void BuildLUTRGBA();
69    void ConvertSwapZone();
70    void ConvertReorderEndianity();
71    bool ConvertReArrangeBits() throw ( FormatError );
72    void ConvertRGBPlanesToRGBPixels();
73    void ConvertYcBcRPlanesToRGBPixels();
74    void ConvertHandleColor();
75
76    void ComputeRawAndRGBSizes();
77    void AllocateRGB();
78    void AllocateRaw();
79
80 // Variables
81    /// Pixel data represented as RGB after LUT color interpretation.
82    uint8_t *RGB;
83    /// Size of RGB image.
84    size_t   RGBSize;
85    /// Pixel data after decompression and bit/byte rearrangement.
86    uint8_t *Raw;
87    /// Size of Decompressed image.
88    size_t   RawSize;
89    /// \brief Red/Green/Blue/Alpha LookUpTable build out of the
90    ///        Red/Green/Blue LUT descriptors (see \ref BuildLUTRGBA ).
91    uint8_t *LutRGBA;
92
93    size_t PixelOffset;
94    size_t PixelDataLength;
95    int XSize;
96    int YSize;
97    int ZSize;
98    int BitsAllocated;
99    int BitsStored;
100    int HighBitPosition;
101    int SamplesPerPixel;
102    int PixelSize;
103    bool PixelSign;
104    int SwapCode;
105
106    bool IsRaw;
107    bool IsJPEG2000;
108    bool IsJPEGLS;
109    bool IsJPEGLossless;
110    bool IsJPEGLossy;
111    bool IsJPEG;
112    bool IsRLELossless;
113
114    RLEFramesInfo *RLEInfo;
115    JPEGFragmentsInfo *JPEGInfo;
116
117    // For handling color stage
118    int PlanarConfiguration;
119    bool IsMonochrome;
120    bool IsPaletteColor;
121    bool IsYBRFull;
122    bool HasLUT;
123    // The 3 LUT descriptors may be different:
124    std::string LutRedDescriptor;
125    std::string LutGreenDescriptor;
126    std::string LutBlueDescriptor;
127    uint8_t *LutRedData;
128    uint8_t *LutGreenData;
129    uint8_t *LutBlueData;
130
131 };
132 } // end namespace gdcm
133
134 //-----------------------------------------------------------------------------
135 #endif