1 /*=========================================================================
4 Module: $RCSfile: gdcmPixelConvert.h,v $
6 Date: $Date: 2004/10/15 10:43:28 $
7 Version: $Revision: 1.9 $
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;
77 //// Setter accessors:
78 void SetXSize( int xSize ) { XSize = xSize; }
79 void SetYSize( int ySize ) { YSize = ySize; }
80 void SetZSize( int zSize ) { ZSize = zSize; }
81 void SetBitsAllocated( int bitsAllocated ) { BitsAllocated = bitsAllocated; }
82 void SetBitsStored( int bitsStored ) { BitsStored = bitsStored; }
83 void SetHighBitPosition( int highBitPosition )
84 { HighBitPosition = highBitPosition; }
85 void SetSamplesPerPixel( int samplesPerPixel )
86 { SamplesPerPixel = samplesPerPixel; }
87 void SetPixelSize( int pixelSize ) { PixelSize = pixelSize; }
88 void SetPixelSign( int pixelSign ) { PixelSign = pixelSign; }
89 void SetSwapCode( int swapCode ) { SwapCode = swapCode; }
90 void SetIsUncompressed( bool isUncompressed )
91 { IsUncompressed = isUncompressed; }
92 void SetIsJPEG2000( bool isJPEG2000 ) { IsJPEG2000 = isJPEG2000; }
93 void SetIsJPEGLossless( bool isJPEGLossless )
94 { IsJPEGLossless = isJPEGLossless; }
95 void SetIsRLELossless( bool isRLELossless )
96 { IsRLELossless = isRLELossless; }
97 void SetPixelOffset( size_t pixelOffset ) { PixelOffset = pixelOffset; }
98 void SetPixelDataLength( size_t pixelDataLength )
99 { PixelDataLength = pixelDataLength; }
100 void SetRLEInfo( RLEFramesInfo* inRLEFramesInfo )
101 { RLEInfo = inRLEFramesInfo; }
102 void SetJPEGInfo( JPEGFragmentsInfo* inJPEGFragmentsInfo )
103 { JPEGInfo = inJPEGFragmentsInfo; }
105 void SetPlanarConfiguration( size_t planarConfiguration )
106 { PlanarConfiguration = planarConfiguration; }
107 void SetIsMonochrome( bool isMonochrome ) { IsMonochrome = isMonochrome; }
108 void SetIsPaletteColor( bool isPaletteColor )
109 { IsPaletteColor = isPaletteColor; }
110 void SetIsYBRFull( bool isYBRFull ) { IsYBRFull = isYBRFull; }
111 void SetHasLUT ( bool hasLUT ) { HasLUT = hasLUT; }
113 void SetRGBSize( size_t size ) { RGBSize = size; }
114 void SetDecompressedSize( size_t size ) { DecompressedSize = size; }
116 //// Getter accessors:
117 uint8_t* GetRGB() { return RGB; }
118 size_t GetRGBSize() { return RGBSize; }
119 uint8_t* GetDecompressed() { return Decompressed; }
120 size_t GetDecompressedSize() { return DecompressedSize; }
123 bool IsDecompressedRGB();
125 //////////////////////////////////////////////////////////
128 bool ReadAndDecompressRLEFragment(
129 uint8_t* decodedZone,
131 long uncompressedSegmentSize,
133 void ReadAndDecompress12BitsTo16Bits( FILE* fp ) throw ( FormatError );
134 bool ReadAndDecompressRLEFile( FILE* fp );
135 bool ReadAndDecompressJPEGFile( FILE* fp );
137 // In place (within Decompressed and with no fp access) decompression
139 bool DecompressRLE16BitsFromRLE8Bits( int NumberOfFrames );
140 void ConvertSwapZone();
141 void ConvertReorderEndianity();
142 bool ConvertReArrangeBits() throw ( FormatError );
143 void ConvertRGBPlanesToRGBPixels();
144 void ConvertYcBcRPlanesToRGBPixels();
145 void ConvertHandleColor();
147 void ComputeDecompressedImageDataSize();
149 void AllocateDecompressed();
152 bool ReadAndDecompressPixelData( FILE* fp );
155 } // end namespace gdcm
157 //-----------------------------------------------------------------------------