1 /*=========================================================================
4 Module: $RCSfile: gdcmPixelReadConvert.h,v $
6 Date: $Date: 2007/09/17 12:18:25 $
7 Version: $Revision: 1.33 $
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_
24 #include "gdcmFileHelper.h"
25 #include "gdcmException.h"
26 #include "gdcmCommandManager.h"
30 namespace GDCM_NAME_SPACE
34 class JPEGFragmentsInfo;
36 typedef void (*VOID_FUNCTION_PUINT8_PFILE_POINTER)(uint8_t *, File *);
39 * \brief Utility container for gathering the various forms the pixel data
40 * migth take during the user demanded processes.
41 * WARNING : *none* of these functions may be invoked by gdcm user
44 class GDCM_EXPORT PixelReadConvert : public Base
46 friend class FileHelper;
50 virtual ~PixelReadConvert();
52 void Print( std::ostream &os = std::cout, std::string const &indent = "" );
55 /// \brief returns pixel area holding RGB Pixels, made from Grey level + LUT
56 uint8_t *GetRGB() { return RGB; }
57 /// \brief returns pixel area length -RGB Pixels, (from Grey level + LUT)-
58 size_t GetRGBSize() { return RGBSize; }
59 /// \brief returns pixel area holding native RGB Pixels or Grey level
60 uint8_t *GetRaw() { return Raw; }
61 /// \brief returns pixel area size -native RGB Pixels or Grey level-
62 size_t GetRawSize() { return RawSize; }
63 /// \brief returns Red Green Blue Alpha LUT
64 uint8_t *GetLutRGBA() { return LutRGBA; }
65 /// \brief returns Lut Item Number
66 int GetLutItemNumber() { return LutItemNumber; }
67 /// \brief returns Lut Item Size
68 int GetLutItemSize() { return LutItemSize; }
73 void GrabInformationsFromFile( File *file, FileHelper *fileHelper );
74 bool ReadAndDecompressPixelData( std::ifstream *fp );
78 /// \brief Allow user to pass his own function to modify pixels
79 /// (e.g; mirror, upsidedown, ...) just after reading
80 void SetUserFunction( VOID_FUNCTION_PUINT8_PFILE_POINTER userFunc )
81 { UserFunction = userFunc; }
84 void ReadAndDecompress12BitsTo16Bits( std::ifstream *fp )
85 throw ( FormatError );
86 bool ReadAndDecompressJPEGFile( std::ifstream *fp );
88 // In place (within Decompressed and with no fp access) decompression
90 void ConvertSwapZone();
91 void ConvertReorderEndianity();
92 bool ConvertReArrangeBits() throw ( FormatError );
93 void ConvertFixGreyLevels();
94 void ConvertRGBPlanesToRGBPixels();
95 void ConvertYcBcRPlanesToRGBPixels();
96 void ConvertHandleColor();
98 void ComputeRawAndRGBSizes();
102 void CallStartMethod();
103 void CallProgressMethod();
104 void CallEndMethod();
108 * \brief Pixel data represented as RGB after LUT color interpretation.
109 * 'uint8_t' is just to avoid warnings at compile time.
110 * feel free to cast it as uint16_t if you need
113 /// Size of RGB image.
115 /// Pixel data after decompression and bit/byte rearrangement.
117 /// Size of Decompressed image.
119 /// \brief Red/Green/Blue/Alpha LookUpTable build out of the
120 /// Red/Green/Blue LUT descriptors (see BuildLUTRGBA ).
125 // *ALL* the following info belong to the FileHelper
126 // One should think there is an analyze error in the model !
129 size_t PixelDataLength;
138 //int PixelSize; // useless
142 // cache whether this is a strange GE transfer syntax (which has
143 // one transfer syntax for the header and another for the pixel data).
144 bool IsPrivateGETransferSyntax;
155 RLEFramesInfo *RLEInfo;
156 JPEGFragmentsInfo *JPEGInfo;
158 // For handling color stage
159 int PlanarConfiguration;
165 // The 3 LUT descriptors may be different:
166 std::string LutRedDescriptor;
167 std::string LutGreenDescriptor;
168 std::string LutBlueDescriptor;
170 uint8_t *LutGreenData;
171 uint8_t *LutBlueData;
173 File *FileInternal; // must be passed to User Function
174 VOID_FUNCTION_PUINT8_PFILE_POINTER UserFunction;
175 /// Needed for the progression bar stuff
180 } // end namespace gdcm
182 //-----------------------------------------------------------------------------