1 /*=========================================================================
4 Module: $RCSfile: gdcmPixelConvert.h,v $
6 Date: $Date: 2004/10/12 09:59:45 $
7 Version: $Revision: 1.7 $
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;
61 RLEFramesInfo* RLEInfo;
62 JPEGFragmentsInfo* JPEGInfo;
65 bool ReadAndUncompressRLEFragment(
68 long uncompressedSegmentSize,
74 void SetXSize( int xSize ) { XSize = xSize; }
75 void SetYSize( int ySize ) { YSize = ySize; }
76 void SetZSize( int zSize ) { ZSize = zSize; }
77 void SetBitsAllocated( int bitsAllocated ) { BitsAllocated = bitsAllocated; }
78 void SetBitsStored( int bitsStored ) { BitsStored = bitsStored; }
79 void SetHighBitPosition( int highBitPosition )
80 { HighBitPosition = highBitPosition; }
81 void SetSamplesPerPixel( int samplesPerPixel )
82 { SamplesPerPixel = samplesPerPixel; }
83 void SetPixelSize( int pixelSize ) { PixelSize = pixelSize; }
84 void SetPixelSign( int pixelSign ) { PixelSign = pixelSign; }
85 void SetSwapCode( int swapCode ) { SwapCode = swapCode; }
86 void SetIsUncompressed( bool isUncompressed )
87 { IsUncompressed = isUncompressed; }
88 void SetIsJPEG2000( bool isJPEG2000 ) { IsJPEG2000 = isJPEG2000; }
89 void SetIsJPEGLossless( bool isJPEGLossless )
90 { IsJPEGLossless = isJPEGLossless; }
91 void SetIsRLELossless( bool isRLELossless )
92 { IsRLELossless = isRLELossless; }
93 void SetPixelOffset( size_t pixelOffset ) { PixelOffset = pixelOffset; }
94 void SetPixelDataLength( size_t pixelDataLength )
95 { PixelDataLength = pixelDataLength; }
96 void SetRLEInfo( RLEFramesInfo* inRLEFramesInfo )
97 { RLEInfo = inRLEFramesInfo; }
98 void SetJPEGInfo( JPEGFragmentsInfo* inJPEGFragmentsInfo )
99 { JPEGInfo = inJPEGFragmentsInfo; }
101 uint8_t* GetRGB() { return RGB; }
102 void SetRGBSize( size_t size ) { RGBSize = size; }
103 size_t GetRGBSize() { return RGBSize; }
106 uint8_t* GetDecompressed() { return Decompressed; }
107 void SetDecompressedSize( size_t size ) { DecompressedSize = size; }
108 size_t GetDecompressedSize() { return DecompressedSize; }
109 void AllocateDecompressed();
111 //////////////////////////////////////////////////////////
114 bool UncompressRLE16BitsFromRLE8Bits(
116 uint8_t* fixMemUncompressed );
117 void ComputeDecompressedImageDataSize();
118 void Decompress12BitsTo16Bits(
120 FILE* filePtr) throw ( FormatError );
121 bool ReadAndDecompressRLEFile( void* image_buffer, FILE* fp );
122 bool ReadAndDecompressJPEGFile( uint8_t* destination, FILE* fp );
123 void SwapZone( uint8_t* im );
125 void ReorderEndianity( uint8_t* pixelZone );
126 bool ReArrangeBits( uint8_t* pixelZone ) throw ( FormatError );
127 void ConvertRGBPlanesToRGBPixels(
128 uint8_t* destination,
129 size_t imageDataSize );
130 void ConvertYcBcRPlanesToRGBPixels(
131 uint8_t* destination,
132 size_t imageDataSize );
133 bool ReadAndDecompressPixelData( void* destination, FILE* fp );
136 } // end namespace gdcm
138 //-----------------------------------------------------------------------------