1 /*=========================================================================
4 Module: $RCSfile: gdcmPixelReadConvert.h,v $
6 Date: $Date: 2005/11/29 17:21:35 $
7 Version: $Revision: 1.28 $
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"
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 gdm 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 \ref 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;
137 //int PixelSize; // useless
141 // cache whether this is a strange GE transfer syntax (which has
142 // one transfer syntax for the header and another for the pixel data).
143 bool IsPrivateGETransferSyntax;
154 RLEFramesInfo *RLEInfo;
155 JPEGFragmentsInfo *JPEGInfo;
157 // For handling color stage
158 int PlanarConfiguration;
164 // The 3 LUT descriptors may be different:
165 std::string LutRedDescriptor;
166 std::string LutGreenDescriptor;
167 std::string LutBlueDescriptor;
169 uint8_t *LutGreenData;
170 uint8_t *LutBlueData;
172 File *FileInternal; // must be passed to User Function
173 VOID_FUNCTION_PUINT8_PFILE_POINTER UserFunction;
174 /// Needed for the progression bar stuff
179 } // end namespace gdcm
181 //-----------------------------------------------------------------------------