1 /*=========================================================================
4 Module: $RCSfile: gdcmPixelReadConvert.h,v $
6 Date: $Date: 2005/10/23 15:09:19 $
7 Version: $Revision: 1.26 $
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 "gdcmException.h"
31 class JPEGFragmentsInfo;
33 typedef void (*VOID_FUNCTION_PUINT8_PFILE_POINTER)(uint8_t *, File *);
36 * \brief Utility container for gathering the various forms the pixel data
37 * migth take during the user demanded processes.
38 * WARNING : *none* of these functions may be invoked by gdm user
41 class GDCM_EXPORT PixelReadConvert : public Base
43 friend class FileHelper;
47 virtual ~PixelReadConvert();
49 void Print( std::ostream &os = std::cout, std::string const &indent = "" );
52 /// \brief returns pixel area holding RGB Pixels, made from Grey level + LUT
53 uint8_t *GetRGB() { return RGB; }
54 /// \brief returns pixel area length -RGB Pixels, (from Grey level + LUT)-
55 size_t GetRGBSize() { return RGBSize; }
56 /// \brief returns pixel area holding native RGB Pixels or Grey level
57 uint8_t *GetRaw() { return Raw; }
58 /// \brief returns pixel area size -native RGB Pixels or Grey level-
59 size_t GetRawSize() { return RawSize; }
60 /// \brief returns Red Green Blue Alpha LUT
61 uint8_t *GetLutRGBA() { return LutRGBA; }
62 /// \brief returns Lut Item Number
63 int GetLutItemNumber() { return LutItemNumber; }
64 /// \brief returns Lut Item Size
65 int GetLutItemSize() { return LutItemSize; }
70 void GrabInformationsFromFile( File *file );
71 bool ReadAndDecompressPixelData( std::ifstream *fp );
75 /// \brief Allow user to pass his own function to modify pixels
76 /// (e.g; mirror, upsidedown, ...) just after reading
77 void SetUserFunction( VOID_FUNCTION_PUINT8_PFILE_POINTER userFunc )
78 { UserFunction = userFunc; }
81 void ReadAndDecompress12BitsTo16Bits( std::ifstream *fp )
82 throw ( FormatError );
83 bool ReadAndDecompressJPEGFile( std::ifstream *fp );
85 // In place (within Decompressed and with no fp access) decompression
87 void ConvertSwapZone();
88 void ConvertReorderEndianity();
89 bool ConvertReArrangeBits() throw ( FormatError );
90 void ConvertFixGreyLevels();
91 void ConvertRGBPlanesToRGBPixels();
92 void ConvertYcBcRPlanesToRGBPixels();
93 void ConvertHandleColor();
95 void ComputeRawAndRGBSizes();
101 * \brief Pixel data represented as RGB after LUT color interpretation.
102 * 'uint8_t' is just to avoid warnings at compile time.
103 * feel free to cast it as uint16_t if you need
106 /// Size of RGB image.
108 /// Pixel data after decompression and bit/byte rearrangement.
110 /// Size of Decompressed image.
112 /// \brief Red/Green/Blue/Alpha LookUpTable build out of the
113 /// Red/Green/Blue LUT descriptors (see \ref BuildLUTRGBA ).
118 // *ALL* the following info belong to the FileHelper
119 // One should think there is an analyze error in the model !
122 size_t PixelDataLength;
130 //int PixelSize; // useless
135 bool IsPrivateGETransferSyntax;
144 RLEFramesInfo *RLEInfo;
145 JPEGFragmentsInfo *JPEGInfo;
147 // For handling color stage
148 int PlanarConfiguration;
154 // The 3 LUT descriptors may be different:
155 std::string LutRedDescriptor;
156 std::string LutGreenDescriptor;
157 std::string LutBlueDescriptor;
159 uint8_t *LutGreenData;
160 uint8_t *LutBlueData;
162 File *FileInternal; // must be passed to User Function
163 VOID_FUNCTION_PUINT8_PFILE_POINTER UserFunction;
165 } // end namespace gdcm
167 //-----------------------------------------------------------------------------