1 /*=========================================================================
4 Module: $RCSfile: gdcmPixelConvert.h,v $
6 Date: $Date: 2004/10/13 14:15:30 $
7 Version: $Revision: 1.8 $
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"
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 {
37 /// Pixel data represented as RGB after color interpretation
39 size_t RGBSize; //aka ImageDataSize
40 /// Pixel data after decompression and bit/byte rearrangement.
41 uint8_t* Decompressed;
42 size_t DecompressedSize;
44 // Set by the accessors:
46 size_t PixelDataLength;
63 RLEFramesInfo* RLEInfo;
64 JPEGFragmentsInfo* JPEGInfo;
66 // For handling color stage
67 int PlanarConfiguration;
73 bool ReadAndUncompressRLEFragment(
76 long uncompressedSegmentSize,
82 void SetXSize( int xSize ) { XSize = xSize; }
83 void SetYSize( int ySize ) { YSize = ySize; }
84 void SetZSize( int zSize ) { ZSize = zSize; }
85 void SetBitsAllocated( int bitsAllocated ) { BitsAllocated = bitsAllocated; }
86 void SetBitsStored( int bitsStored ) { BitsStored = bitsStored; }
87 void SetHighBitPosition( int highBitPosition )
88 { HighBitPosition = highBitPosition; }
89 void SetSamplesPerPixel( int samplesPerPixel )
90 { SamplesPerPixel = samplesPerPixel; }
91 void SetPixelSize( int pixelSize ) { PixelSize = pixelSize; }
92 void SetPixelSign( int pixelSign ) { PixelSign = pixelSign; }
93 void SetSwapCode( int swapCode ) { SwapCode = swapCode; }
94 void SetIsUncompressed( bool isUncompressed )
95 { IsUncompressed = isUncompressed; }
96 void SetIsJPEG2000( bool isJPEG2000 ) { IsJPEG2000 = isJPEG2000; }
97 void SetIsJPEGLossless( bool isJPEGLossless )
98 { IsJPEGLossless = isJPEGLossless; }
99 void SetIsRLELossless( bool isRLELossless )
100 { IsRLELossless = isRLELossless; }
101 void SetPixelOffset( size_t pixelOffset ) { PixelOffset = pixelOffset; }
102 void SetPixelDataLength( size_t pixelDataLength )
103 { PixelDataLength = pixelDataLength; }
104 void SetRLEInfo( RLEFramesInfo* inRLEFramesInfo )
105 { RLEInfo = inRLEFramesInfo; }
106 void SetJPEGInfo( JPEGFragmentsInfo* inJPEGFragmentsInfo )
107 { JPEGInfo = inJPEGFragmentsInfo; }
109 void SetPlanarConfiguration( size_t planarConfiguration )
110 { PlanarConfiguration = planarConfiguration; }
111 void SetIsMonochrome( bool isMonochrome ) { IsMonochrome = isMonochrome; }
112 void SetIsPaletteColor( bool isPaletteColor )
113 { IsPaletteColor = isPaletteColor; }
114 void SetIsYBRFull( bool isYBRFull ) { IsYBRFull = isYBRFull; }
116 uint8_t* GetRGB() { return RGB; }
117 void SetRGBSize( size_t size ) { RGBSize = size; }
118 size_t GetRGBSize() { return RGBSize; }
121 uint8_t* GetDecompressed() { return Decompressed; }
122 void SetDecompressedSize( size_t size ) { DecompressedSize = size; }
123 size_t GetDecompressedSize() { return DecompressedSize; }
124 void AllocateDecompressed();
126 //////////////////////////////////////////////////////////
129 bool UncompressRLE16BitsFromRLE8Bits(
131 uint8_t* fixMemUncompressed );
132 void ComputeDecompressedImageDataSize();
133 void ReadAndDecompress12BitsTo16Bits(
135 FILE* filePtr) throw ( FormatError );
136 bool ReadAndDecompressRLEFile( void* image_buffer, FILE* fp );
137 bool ReadAndDecompressJPEGFile( uint8_t* destination, FILE* fp );
138 void SwapZone( uint8_t* im );
139 void ReorderEndianity( uint8_t* pixelZone );
140 bool ReArrangeBits( uint8_t* pixelZone ) throw ( FormatError );
141 void ConvertRGBPlanesToRGBPixels( uint8_t* destination );
142 void ConvertYcBcRPlanesToRGBPixels( uint8_t* destination );
144 bool ReadAndDecompressPixelData( void* destination, FILE* fp );
145 bool HandleColor( uint8_t* destination );
148 } // end namespace gdcm
150 //-----------------------------------------------------------------------------