1 /*=========================================================================
4 Module: $RCSfile: gdcmPixelReadConvert.h,v $
6 Date: $Date: 2004/12/16 11:37:03 $
7 Version: $Revision: 1.6 $
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::ostream &os = std::cout );
52 void Print( std::string indent = "", std::ostream &os = std::cout );
55 void GrabInformationsFromHeader( Header* header );
56 bool ReadAndDecompressPixelData( std::ifstream* fp );
62 bool ReadAndDecompressRLEFragment(
63 uint8_t* subDecompressed,
65 long decompressedSegmentSize,
67 void ReadAndDecompress12BitsTo16Bits( std::ifstream* fp ) throw ( FormatError );
68 bool ReadAndDecompressRLEFile( std::ifstream* fp );
69 bool ReadAndDecompressJPEGFile( std::ifstream* fp );
70 bool ReadAndDecompressJPEGFramesFromFile( std::ifstream* fp );
71 bool ReadAndDecompressJPEGSingleFrameFragmentsFromFile( std::ifstream* fp );
72 bool ReadAndDecompressJPEGFragmentedFramesFromFile( std::ifstream* fp );
75 void BuildLUTRGBA( std::ifstream* fp );
77 // In place (within Decompressed and with no fp access) decompression
80 bool DecompressRLE16BitsFromRLE8Bits( int NumberOfFrames );
81 void ConvertSwapZone();
82 void ConvertReorderEndianity();
83 bool ConvertReArrangeBits() throw ( FormatError );
84 void ConvertRGBPlanesToRGBPixels();
85 void ConvertYcBcRPlanesToRGBPixels();
86 void ConvertHandleColor();
88 void ComputeRawAndRGBSizes();
93 /// Pixel data represented as RGB after LUT color interpretation.
95 /// Size of \ref RGB image.
97 /// Pixel data after decompression and bit/byte rearrangement.
99 /// Size of \ref Decompressed image.
101 /// \brief Red/Green/Blue/Alpha LookUpTable build out of the
102 /// Red/Green/Blue LUT descriptors (see \ref BuildLUTRGBA ).
106 size_t PixelDataLength;
123 RLEFramesInfo* RLEInfo;
124 JPEGFragmentsInfo* JPEGInfo;
126 // For handling color stage
127 int PlanarConfiguration;
132 // The 3 LUT descriptors may be different:
133 std::string LutRedDescriptor;
134 std::string LutGreenDescriptor;
135 std::string LutBlueDescriptor;
137 uint8_t* LutGreenData;
138 uint8_t* LutBlueData;
141 } // end namespace gdcm
143 //-----------------------------------------------------------------------------