gdcmPixelReadConvert.h

Go to the documentation of this file.
00001 /*=========================================================================
00002                                                                                 
00003   Program:   gdcm
00004   Module:    $RCSfile: gdcmPixelReadConvert.h,v $
00005   Language:  C++
00006   Date:      $Date: 2007/08/22 16:14:04 $
00007   Version:   $Revision: 1.32 $
00008                                                                                 
00009   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
00010   l'Image). All rights reserved. See Doc/License.txt or
00011   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
00012                                                                                 
00013      This software is distributed WITHOUT ANY WARRANTY; without even
00014      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00015      PURPOSE.  See the above copyright notices for more information.
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    // Getter accessors:
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    // Predicates:
00070    bool IsRawRGB();
00071 
00072 // In progress
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    // Use the fp:
00084    void ReadAndDecompress12BitsTo16Bits( std::ifstream *fp ) 
00085                                  throw ( FormatError );
00086    bool ReadAndDecompressJPEGFile( std::ifstream *fp );
00087 
00088    // In place (within Decompressed and with no fp access) decompression
00089    // or convertion:
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 // Variables
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    // *ALL* the following info belong to the FileHelper
00126    // One should think there is an analyze error in the model !
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    //int PixelSize; // useless
00139    bool PixelSign;
00140    int SwapCode;
00141 
00142    // cache whether this is a strange GE transfer syntax (which has   
00143    // one transfer syntax for the header and another for the pixel data).
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    // For handling color stage
00159    int PlanarConfiguration;
00160    bool IsMonochrome;
00161    bool IsMonochrome1;
00162    bool IsPaletteColor;
00163    bool IsYBRFull;
00164    bool HasLUT;
00165    // The 3 LUT descriptors may be different:
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; // must be passed to User Function
00174    VOID_FUNCTION_PUINT8_PFILE_POINTER UserFunction;
00176    FileHelper *FH;
00177    mutable bool Abort;
00178    float Progress;
00179 };
00180 } // end namespace gdcm
00181 
00182 //-----------------------------------------------------------------------------
00183 #endif

Generated on Fri Aug 24 12:59:31 2007 for gdcm by  doxygen 1.4.6