00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GDCMPIXELREADCONVERT_H
00021 #define GDCMPIXELREADCONVERT_H
00022
00023 #include "gdcmCommon.h"
00024 #include "gdcmBase.h"
00025 #include "gdcmException.h"
00026
00027 namespace gdcm
00028 {
00029 class File;
00030 class RLEFramesInfo;
00031 class JPEGFragmentsInfo;
00032
00037 class GDCM_EXPORT PixelReadConvert : public Base
00038 {
00039 public:
00040 PixelReadConvert();
00041 virtual ~PixelReadConvert();
00042
00043 void Print( std::ostream &os = std::cout, std::string const &indent = "" );
00044
00045
00046 uint8_t *GetRGB() { return RGB; }
00047 size_t GetRGBSize() { return RGBSize; }
00048 uint8_t *GetRaw() { return Raw; }
00049 size_t GetRawSize() { return RawSize; }
00050 uint8_t *GetLutRGBA() { return LutRGBA; }
00051
00052
00053 bool IsRawRGB();
00054
00055
00056 void GrabInformationsFromFile( File *file );
00057 bool ReadAndDecompressPixelData( std::ifstream *fp );
00058 void Squeeze();
00059 bool BuildRGBImage();
00060
00061 private:
00062
00063 void ReadAndDecompress12BitsTo16Bits( std::ifstream *fp )
00064 throw ( FormatError );
00065 bool ReadAndDecompressJPEGFile( std::ifstream *fp );
00066
00067
00068
00069 void BuildLUTRGBA();
00070 void ConvertSwapZone();
00071 void ConvertReorderEndianity();
00072 bool ConvertReArrangeBits() throw ( FormatError );
00073 void ConvertRGBPlanesToRGBPixels();
00074 void ConvertYcBcRPlanesToRGBPixels();
00075 void ConvertHandleColor();
00076
00077 void ComputeRawAndRGBSizes();
00078 void AllocateRGB();
00079 void AllocateRaw();
00080
00081
00083 uint8_t *RGB;
00085 size_t RGBSize;
00087 uint8_t *Raw;
00089 size_t RawSize;
00092 uint8_t *LutRGBA;
00093
00094 size_t PixelOffset;
00095 size_t PixelDataLength;
00096 int XSize;
00097 int YSize;
00098 int ZSize;
00099 int BitsAllocated;
00100 int BitsStored;
00101 int HighBitPosition;
00102 int SamplesPerPixel;
00103 int PixelSize;
00104 bool PixelSign;
00105 int SwapCode;
00106
00107 bool IsRaw;
00108 bool IsJPEG2000;
00109 bool IsJPEGLS;
00110 bool IsJPEGLossless;
00111 bool IsJPEGLossy;
00112 bool IsJPEG;
00113 bool IsRLELossless;
00114
00115 RLEFramesInfo *RLEInfo;
00116 JPEGFragmentsInfo *JPEGInfo;
00117
00118
00119 int PlanarConfiguration;
00120 bool IsMonochrome;
00121 bool IsPaletteColor;
00122 bool IsYBRFull;
00123 bool HasLUT;
00124
00125 std::string LutRedDescriptor;
00126 std::string LutGreenDescriptor;
00127 std::string LutBlueDescriptor;
00128 uint8_t *LutRedData;
00129 uint8_t *LutGreenData;
00130 uint8_t *LutBlueData;
00131
00132 };
00133 }
00134
00135
00136 #endif