1 /*=========================================================================
4 Module: $RCSfile: gdcmPixelConvert.h,v $
6 Date: $Date: 2004/10/20 14:30:40 $
7 Version: $Revision: 1.11 $
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 GDCMPIXELCONVERTL_H
23 #include "gdcmCommon.h"
24 #include "gdcmRLEFramesInfo.h"
25 #include "gdcmJPEGFragmentsInfo.h"
26 #include "gdcmException.h"
27 #include "gdcmHeader.h"
33 * \brief Utility container for gathering the various forms the pixel data
34 * migth take during the user demanded processes.
36 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( FILE* fp );
57 bool BuildRGBImage( FILE* fp );
61 bool ReadAndDecompressRLEFragment(
62 uint8_t* subDecompressed,
64 long decompressedSegmentSize,
66 void ReadAndDecompress12BitsTo16Bits( FILE* fp ) throw ( FormatError );
67 bool ReadAndDecompressRLEFile( FILE* fp );
68 bool ReadAndDecompressJPEGFile( FILE* fp );
69 void BuildLUTRGBA( FILE* fp );
71 // In place (within Decompressed and with no fp access) decompression
73 bool DecompressRLE16BitsFromRLE8Bits( int NumberOfFrames );
74 void ConvertSwapZone();
75 void ConvertReorderEndianity();
76 bool ConvertReArrangeBits() throw ( FormatError );
77 void ConvertRGBPlanesToRGBPixels();
78 void ConvertYcBcRPlanesToRGBPixels();
79 void ConvertHandleColor();
81 void ComputeDecompressedAndRGBSizes();
83 void AllocateDecompressed();
86 /// Pixel data represented as RGB after LUT color interpretation.
88 /// Size of \ref RGB image.
90 /// Pixel data after decompression and bit/byte rearrangement.
91 uint8_t* Decompressed;
92 /// Size of \ref Decompressed image.
93 size_t DecompressedSize;
94 /// \brief Red/Green/Blue/Alpha LookUpTable build out of the
95 /// Red/Green/Blue LUT descriptors (see \ref BuildLUTRGBA ).
99 size_t PixelDataLength;
116 RLEFramesInfo* RLEInfo;
117 JPEGFragmentsInfo* JPEGInfo;
119 // For handling color stage
120 int PlanarConfiguration;
125 // The 3 LUT descriptors may be different:
126 std::string LutRedDescriptor;
127 std::string LutGreenDescriptor;
128 std::string LutBlueDescriptor;
130 uint8_t* LutGreenData;
131 uint8_t* LutBlueData;
134 } // end namespace gdcm
136 //-----------------------------------------------------------------------------