1 /*=========================================================================
4 Module: $RCSfile: gdcmPixelConvert.h,v $
6 Date: $Date: 2004/10/25 04:08:20 $
7 Version: $Revision: 1.14 $
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 GDCMPIXELCONVERT_H
21 #define GDCMPIXELCONVERT_H
23 #include "gdcmCommon.h"
24 #include "gdcmRLEFramesInfo.h"
25 #include "gdcmJPEGFragmentsInfo.h"
26 #include "gdcmException.h"
27 #include "gdcmHeader.h"
32 * \brief Utility container for gathering the various forms the pixel data
33 * migth take during the user demanded processes.
35 class GDCM_EXPORT PixelConvert
41 //// Getter accessors:
42 uint8_t* GetRGB() { return RGB; }
43 size_t GetRGBSize() { return RGBSize; }
44 uint8_t* GetDecompressed() { return Decompressed; }
45 size_t GetDecompressedSize() { return DecompressedSize; }
46 uint8_t* GetLutRGBA() { return LutRGBA; }
49 bool IsDecompressedRGB();
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 void BuildLUTRGBA( std::ifstream* fp );
71 // In place (within Decompressed and with no fp access) decompression
74 bool DecompressRLE16BitsFromRLE8Bits( int NumberOfFrames );
75 void ConvertSwapZone();
76 void ConvertReorderEndianity();
77 bool ConvertReArrangeBits() throw ( FormatError );
78 void ConvertRGBPlanesToRGBPixels();
79 void ConvertYcBcRPlanesToRGBPixels();
80 void ConvertHandleColor();
82 void ComputeDecompressedAndRGBSizes();
84 void AllocateDecompressed();
87 /// Pixel data represented as RGB after LUT color interpretation.
89 /// Size of \ref RGB image.
91 /// Pixel data after decompression and bit/byte rearrangement.
92 uint8_t* Decompressed;
93 /// Size of \ref Decompressed image.
94 size_t DecompressedSize;
95 /// \brief Red/Green/Blue/Alpha LookUpTable build out of the
96 /// Red/Green/Blue LUT descriptors (see \ref BuildLUTRGBA ).
100 size_t PixelDataLength;
117 RLEFramesInfo* RLEInfo;
118 JPEGFragmentsInfo* JPEGInfo;
120 // For handling color stage
121 int PlanarConfiguration;
126 // The 3 LUT descriptors may be different:
127 std::string LutRedDescriptor;
128 std::string LutGreenDescriptor;
129 std::string LutBlueDescriptor;
131 uint8_t* LutGreenData;
132 uint8_t* LutBlueData;
135 } // end namespace gdcm
137 //-----------------------------------------------------------------------------