X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmPixelConvert.h;h=74a01d1e0a3625e8dc4fd315d546bfd3c0aa1a37;hb=5bf7c51796867388334836847a6874640bc83f89;hp=9c67e06af10ed558a62ff570055e32fdcf701c1e;hpb=4672e071f29ed17f7258b27e40d47642abfbb53f;p=gdcm.git diff --git a/src/gdcmPixelConvert.h b/src/gdcmPixelConvert.h index 9c67e06a..74a01d1e 100644 --- a/src/gdcmPixelConvert.h +++ b/src/gdcmPixelConvert.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmPixelConvert.h,v $ Language: C++ - Date: $Date: 2004/10/13 14:15:30 $ - Version: $Revision: 1.8 $ + Date: $Date: 2004/10/20 14:30:40 $ + Version: $Revision: 1.11 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -24,6 +24,7 @@ #include "gdcmRLEFramesInfo.h" #include "gdcmJPEGFragmentsInfo.h" #include "gdcmException.h" +#include "gdcmHeader.h" namespace gdcm { @@ -33,15 +34,67 @@ namespace gdcm * migth take during the user demanded processes. */ class GDCM_EXPORT PixelConvert { -friend class File; - /// Pixel data represented as RGB after color interpretation +public: + PixelConvert(); + ~PixelConvert(); + + //// Getter accessors: + uint8_t* GetRGB() { return RGB; } + size_t GetRGBSize() { return RGBSize; } + uint8_t* GetDecompressed() { return Decompressed; } + size_t GetDecompressedSize() { return DecompressedSize; } + uint8_t* GetLutRGBA() { return LutRGBA; } + + //// Predicates: + bool IsDecompressedRGB(); + + void Print( std::string indent = "", std::ostream &os = std::cout ); + +// In progress + void GrabInformationsFromHeader( Header* header ); + bool ReadAndDecompressPixelData( FILE* fp ); + void Squeeze(); + bool BuildRGBImage( FILE* fp ); + +private: + // Use the fp: + bool ReadAndDecompressRLEFragment( + uint8_t* subDecompressed, + long fragmentSize, + long decompressedSegmentSize, + FILE* fp ); + void ReadAndDecompress12BitsTo16Bits( FILE* fp ) throw ( FormatError ); + bool ReadAndDecompressRLEFile( FILE* fp ); + bool ReadAndDecompressJPEGFile( FILE* fp ); + void BuildLUTRGBA( FILE* fp ); + + // In place (within Decompressed and with no fp access) decompression + // or convertion: + bool DecompressRLE16BitsFromRLE8Bits( int NumberOfFrames ); + void ConvertSwapZone(); + void ConvertReorderEndianity(); + bool ConvertReArrangeBits() throw ( FormatError ); + void ConvertRGBPlanesToRGBPixels(); + void ConvertYcBcRPlanesToRGBPixels(); + void ConvertHandleColor(); + + void ComputeDecompressedAndRGBSizes(); + void AllocateRGB(); + void AllocateDecompressed(); + +// Variables + /// Pixel data represented as RGB after LUT color interpretation. uint8_t* RGB; - size_t RGBSize; //aka ImageDataSize + /// Size of \ref RGB image. + size_t RGBSize; /// Pixel data after decompression and bit/byte rearrangement. uint8_t* Decompressed; + /// Size of \ref Decompressed image. size_t DecompressedSize; + /// \brief Red/Green/Blue/Alpha LookUpTable build out of the + /// Red/Green/Blue LUT descriptors (see \ref BuildLUTRGBA ). + uint8_t* LutRGBA; - // Set by the accessors: size_t PixelOffset; size_t PixelDataLength; int XSize; @@ -55,7 +108,7 @@ friend class File; bool PixelSign; int SwapCode; - bool IsUncompressed; + bool IsDecompressed; bool IsJPEG2000; bool IsJPEGLossless; bool IsRLELossless; @@ -68,82 +121,15 @@ friend class File; bool IsMonochrome; bool IsPaletteColor; bool IsYBRFull; + bool HasLUT; + // The 3 LUT descriptors may be different: + std::string LutRedDescriptor; + std::string LutGreenDescriptor; + std::string LutBlueDescriptor; + uint8_t* LutRedData; + uint8_t* LutGreenData; + uint8_t* LutBlueData; -private: - bool ReadAndUncompressRLEFragment( - uint8_t* decodedZone, - long fragmentSize, - long uncompressedSegmentSize, - FILE* fp ); -public: - PixelConvert(); - ~PixelConvert(); - - void SetXSize( int xSize ) { XSize = xSize; } - void SetYSize( int ySize ) { YSize = ySize; } - void SetZSize( int zSize ) { ZSize = zSize; } - void SetBitsAllocated( int bitsAllocated ) { BitsAllocated = bitsAllocated; } - void SetBitsStored( int bitsStored ) { BitsStored = bitsStored; } - void SetHighBitPosition( int highBitPosition ) - { HighBitPosition = highBitPosition; } - void SetSamplesPerPixel( int samplesPerPixel ) - { SamplesPerPixel = samplesPerPixel; } - void SetPixelSize( int pixelSize ) { PixelSize = pixelSize; } - void SetPixelSign( int pixelSign ) { PixelSign = pixelSign; } - void SetSwapCode( int swapCode ) { SwapCode = swapCode; } - void SetIsUncompressed( bool isUncompressed ) - { IsUncompressed = isUncompressed; } - void SetIsJPEG2000( bool isJPEG2000 ) { IsJPEG2000 = isJPEG2000; } - void SetIsJPEGLossless( bool isJPEGLossless ) - { IsJPEGLossless = isJPEGLossless; } - void SetIsRLELossless( bool isRLELossless ) - { IsRLELossless = isRLELossless; } - void SetPixelOffset( size_t pixelOffset ) { PixelOffset = pixelOffset; } - void SetPixelDataLength( size_t pixelDataLength ) - { PixelDataLength = pixelDataLength; } - void SetRLEInfo( RLEFramesInfo* inRLEFramesInfo ) - { RLEInfo = inRLEFramesInfo; } - void SetJPEGInfo( JPEGFragmentsInfo* inJPEGFragmentsInfo ) - { JPEGInfo = inJPEGFragmentsInfo; } - - void SetPlanarConfiguration( size_t planarConfiguration ) - { PlanarConfiguration = planarConfiguration; } - void SetIsMonochrome( bool isMonochrome ) { IsMonochrome = isMonochrome; } - void SetIsPaletteColor( bool isPaletteColor ) - { IsPaletteColor = isPaletteColor; } - void SetIsYBRFull( bool isYBRFull ) { IsYBRFull = isYBRFull; } - - uint8_t* GetRGB() { return RGB; } - void SetRGBSize( size_t size ) { RGBSize = size; } - size_t GetRGBSize() { return RGBSize; } - void AllocateRGB(); - - uint8_t* GetDecompressed() { return Decompressed; } - void SetDecompressedSize( size_t size ) { DecompressedSize = size; } - size_t GetDecompressedSize() { return DecompressedSize; } - void AllocateDecompressed(); - -////////////////////////////////////////////////////////// -// In progress -private: - bool UncompressRLE16BitsFromRLE8Bits( - int NumberOfFrames, - uint8_t* fixMemUncompressed ); - void ComputeDecompressedImageDataSize(); - void ReadAndDecompress12BitsTo16Bits( - uint8_t* pixelZone, - FILE* filePtr) throw ( FormatError ); - bool ReadAndDecompressRLEFile( void* image_buffer, FILE* fp ); - bool ReadAndDecompressJPEGFile( uint8_t* destination, FILE* fp ); - void SwapZone( uint8_t* im ); - void ReorderEndianity( uint8_t* pixelZone ); - bool ReArrangeBits( uint8_t* pixelZone ) throw ( FormatError ); - void ConvertRGBPlanesToRGBPixels( uint8_t* destination ); - void ConvertYcBcRPlanesToRGBPixels( uint8_t* destination ); -public: - bool ReadAndDecompressPixelData( void* destination, FILE* fp ); - bool HandleColor( uint8_t* destination ); - void Squeeze(); }; } // end namespace gdcm