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 "gdcmBase.h"
00024 #include "gdcmFileHelper.h"
00025 #include "gdcmException.h"
00026 #include "gdcmCommandManager.h"
00027 
00028 #include <fstream>
00029 
00030 namespace GDCM_NAME_SPACE
00031 {
00032 class File;
00033 class RLEFramesInfo;
00034 class JPEGFragmentsInfo;
00035 
00036 typedef void (*VOID_FUNCTION_PUINT8_PFILE_POINTER)(uint8_t *, File *);
00037 
00044 class GDCM_EXPORT PixelReadConvert : public Base
00045 {
00046 friend class FileHelper;
00047 
00048 private:
00049    PixelReadConvert();
00050    virtual ~PixelReadConvert();
00051 
00052    void Print( std::ostream &os = std::cout, std::string const &indent = "" );
00053 
00054    
00056    uint8_t *GetRGB()           { return RGB;     }
00058    size_t   GetRGBSize()       { return RGBSize; }
00060    uint8_t *GetRaw()           { return Raw;     }
00062    size_t   GetRawSize()       { return RawSize; }
00064    uint8_t *GetLutRGBA()       { return LutRGBA; }
00066    int      GetLutItemNumber() { return LutItemNumber; }
00068    int      GetLutItemSize()   { return LutItemSize;   }
00069    
00070    bool IsRawRGB();
00071 
00072 
00073    void GrabInformationsFromFile( File *file, FileHelper *fileHelper );
00074    bool ReadAndDecompressPixelData( std::ifstream *fp );
00075    void Squeeze();
00076    bool BuildRGBImage();
00077    void BuildLUTRGBA();
00080    void SetUserFunction( VOID_FUNCTION_PUINT8_PFILE_POINTER userFunc ) 
00081                          { UserFunction = userFunc; }
00082 
00083    
00084    void ReadAndDecompress12BitsTo16Bits( std::ifstream *fp ) 
00085                                  throw ( FormatError );
00086    bool ReadAndDecompressJPEGFile( std::ifstream *fp );
00087 
00088    
00089    
00090    void ConvertSwapZone();
00091    void ConvertReorderEndianity();
00092    bool ConvertReArrangeBits() throw ( FormatError );
00093    void ConvertFixGreyLevels();
00094    void ConvertRGBPlanesToRGBPixels();
00095    void ConvertYcBcRPlanesToRGBPixels();
00096    void ConvertHandleColor();
00097 
00098    void ComputeRawAndRGBSizes();
00099    void AllocateRGB();
00100    void AllocateRaw();
00101 
00102    void CallStartMethod();
00103    void CallProgressMethod();
00104    void CallEndMethod();
00105    
00106 
00112    uint8_t *RGB;
00114    size_t   RGBSize;
00116    uint8_t *Raw;
00118    size_t   RawSize;
00121    uint8_t *LutRGBA;
00122    int LutItemNumber;
00123    int LutItemSize;
00124 
00125    
00126    
00127 
00128    size_t PixelOffset;
00129    size_t PixelDataLength;
00130    int XSize;
00131    int YSize;
00132    int ZSize;
00133    int TSize;
00134    int BitsAllocated;
00135    int BitsStored;
00136    int HighBitPosition;
00137    int SamplesPerPixel;
00138    
00139    bool PixelSign;
00140    int SwapCode;
00141 
00142    
00143    
00144    bool IsPrivateGETransferSyntax;
00145 
00146    bool IsRaw;
00147    bool IsJPEG2000;
00148    bool IsJPEGLS;
00149    bool IsJPEGLossless;
00150    bool IsJPEGLossy;
00151    bool IsJPEG;
00152    bool IsRLELossless;
00153    bool IsMPEG;
00154 
00155    RLEFramesInfo *RLEInfo;
00156    JPEGFragmentsInfo *JPEGInfo;
00157 
00158    
00159    int PlanarConfiguration;
00160    bool IsMonochrome;
00161    bool IsMonochrome1;
00162    bool IsPaletteColor;
00163    bool IsYBRFull;
00164    bool HasLUT;
00165    
00166    std::string LutRedDescriptor;
00167    std::string LutGreenDescriptor;
00168    std::string LutBlueDescriptor;
00169    uint8_t *LutRedData;
00170    uint8_t *LutGreenData;
00171    uint8_t *LutBlueData;
00172    
00173    File *FileInternal; 
00174    VOID_FUNCTION_PUINT8_PFILE_POINTER UserFunction;
00176    FileHelper *FH;
00177    mutable bool Abort;
00178    float Progress;
00179 };
00180 } 
00181 
00182 
00183 #endif