1 /*=========================================================================
4 Module: $RCSfile: gdcmPixelReadConvert.h,v $
6 Date: $Date: 2004/12/12 17:21:07 $
7 Version: $Revision: 1.5 $
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 =========================================================================*/
20 #ifndef GDCMPIXELREADCONVERT_H
21 #define GDCMPIXELREADCONVERT_H
23 #include "gdcmCommon.h"
24 #include "gdcmException.h"
30 class JPEGFragmentsInfo;
32 * \brief Utility container for gathering the various forms the pixel data
33 * migth take during the user demanded processes.
35 class GDCM_EXPORT PixelReadConvert
39 virtual ~PixelReadConvert();
41 //// Getter accessors:
42 uint8_t* GetRGB() { return RGB; }
43 size_t GetRGBSize() { return RGBSize; }
44 uint8_t* GetRaw() { return Raw; }
45 size_t GetRawSize() { return RawSize; }
46 uint8_t* GetLutRGBA() { return LutRGBA; }
51 void Print( std::string indent = "", std::ostream &os = std::cout );
54 void GrabInformationsFromHeader( Header* header );
55 bool ReadAndDecompressPixelData( std::ifstream* fp );
61 bool ReadAndDecompressRLEFragment(
62 uint8_t* subDecompressed,
64 long decompressedSegmentSize,
66 void ReadAndDecompress12BitsTo16Bits( std::ifstream* fp ) throw ( FormatError );
67 bool ReadAndDecompressRLEFile( std::ifstream* fp );
68 bool ReadAndDecompressJPEGFile( std::ifstream* fp );
69 bool ReadAndDecompressJPEGFramesFromFile( std::ifstream* fp );
70 bool ReadAndDecompressJPEGSingleFrameFragmentsFromFile( std::ifstream* fp );
71 bool ReadAndDecompressJPEGFragmentedFramesFromFile( std::ifstream* fp );
74 void BuildLUTRGBA( std::ifstream* fp );
76 // In place (within Decompressed and with no fp access) decompression
79 bool DecompressRLE16BitsFromRLE8Bits( int NumberOfFrames );
80 void ConvertSwapZone();
81 void ConvertReorderEndianity();
82 bool ConvertReArrangeBits() throw ( FormatError );
83 void ConvertRGBPlanesToRGBPixels();
84 void ConvertYcBcRPlanesToRGBPixels();
85 void ConvertHandleColor();
87 void ComputeRawAndRGBSizes();
92 /// Pixel data represented as RGB after LUT color interpretation.
94 /// Size of \ref RGB image.
96 /// Pixel data after decompression and bit/byte rearrangement.
98 /// Size of \ref Decompressed image.
100 /// \brief Red/Green/Blue/Alpha LookUpTable build out of the
101 /// Red/Green/Blue LUT descriptors (see \ref BuildLUTRGBA ).
105 size_t PixelDataLength;
122 RLEFramesInfo* RLEInfo;
123 JPEGFragmentsInfo* JPEGInfo;
125 // For handling color stage
126 int PlanarConfiguration;
131 // The 3 LUT descriptors may be different:
132 std::string LutRedDescriptor;
133 std::string LutGreenDescriptor;
134 std::string LutBlueDescriptor;
136 uint8_t* LutGreenData;
137 uint8_t* LutBlueData;
140 } // end namespace gdcm
142 //-----------------------------------------------------------------------------