X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmPixelConvert.h;h=784c2e0e6b81cad59a94c8c9f7e60b67403c7404;hb=40b909789581894e57a0d8f22d6f1f91f55e7f84;hp=1dd425a0d97415cfc97984cafb476d0465bcb95c;hpb=67845c7dc1241480f5c5fcfa0cfc2e86918dad1e;p=gdcm.git diff --git a/src/gdcmPixelConvert.h b/src/gdcmPixelConvert.h index 1dd425a0..784c2e0e 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/08 16:27:20 $ - Version: $Revision: 1.3 $ + Date: $Date: 2004/10/15 10:43:28 $ + Version: $Revision: 1.9 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -22,66 +22,137 @@ #include "gdcmCommon.h" #include "gdcmRLEFramesInfo.h" +#include "gdcmJPEGFragmentsInfo.h" +#include "gdcmException.h" +namespace gdcm +{ + /* * \brief Utility container for gathering the various forms the pixel data * migth take during the user demanded processes. */ -class GDCM_EXPORT gdcmPixelConvert { -friend class gdcmFile; +class GDCM_EXPORT PixelConvert { +friend class File; /// Pixel data represented as RGB after color interpretation uint8_t* RGB; size_t RGBSize; //aka ImageDataSize /// Pixel data after decompression and bit/byte rearrangement. - uint8_t* Uncompressed; - size_t UncompressedSize; + uint8_t* Decompressed; + size_t DecompressedSize; + + // Set by the accessors: + size_t PixelOffset; + size_t PixelDataLength; + int XSize; + int YSize; + int ZSize; + int BitsAllocated; + int BitsStored; + int HighBitPosition; + int SamplesPerPixel; + int PixelSize; + bool PixelSign; + int SwapCode; + + bool IsUncompressed; + bool IsJPEG2000; + bool IsJPEGLossless; + bool IsRLELossless; + + RLEFramesInfo* RLEInfo; + JPEGFragmentsInfo* JPEGInfo; + + // For handling color stage + int PlanarConfiguration; + bool IsMonochrome; + bool IsPaletteColor; + bool IsYBRFull; + bool HasLUT; + public: - gdcmPixelConvert(); - ~gdcmPixelConvert(); + PixelConvert(); + ~PixelConvert(); - uint8_t* GetRGB() { return RGB; } + //// Setter accessors: + 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; } + void SetHasLUT ( bool hasLUT ) { HasLUT = hasLUT; } + void SetRGBSize( size_t size ) { RGBSize = size; } + void SetDecompressedSize( size_t size ) { DecompressedSize = size; } + + //// Getter accessors: + uint8_t* GetRGB() { return RGB; } size_t GetRGBSize() { return RGBSize; } - void AllocateRGB(); + uint8_t* GetDecompressed() { return Decompressed; } + size_t GetDecompressedSize() { return DecompressedSize; } - uint8_t* GetUncompressed() { return Uncompressed; } - void SetUncompressedSize( size_t size ) { UncompressedSize = size; } - size_t GetUncompressedSize() { return UncompressedSize; } - void AllocateUncompressed(); + //// Predicates: + bool IsDecompressedRGB(); - void Squeeze(); ////////////////////////////////////////////////////////// -// In progress -bool ReadAndUncompress12Bits( FILE* filePointer, - size_t uncompressedSize, - size_t PixelNumber ); -bool ReadUncompressed( FILE* filePointer, - size_t uncompressedSize, - size_t expectedSize ); -bool ConvertGrayAndLutToRGB( uint8_t *lutRGBA ); -bool ReadAndUncompressRLE8Bits(FILE* fp, size_t uncompressedSize ); -static bool UncompressRLE16BitsFromRLE8Bits( - int XSize, - int YSize, - int NumberOfFrames, - uint8_t* fixMemUncompressed ); -static bool ReadAndUncompressRLEFragment( - uint8_t* decodedZone, - long fragmentSize, - long uncompressedSegmentSize, - FILE* fp ); -static bool gdcm_read_RLE_file ( void* image_buffer, - int XSize, - int YSize, - int ZSize, - int BitsAllocated, - gdcmRLEFramesInfo* RLEInfo, - FILE* fp ); +private: + // Use the fp: + bool ReadAndDecompressRLEFragment( + uint8_t* decodedZone, + long fragmentSize, + long uncompressedSegmentSize, + FILE* fp ); + void ReadAndDecompress12BitsTo16Bits( FILE* fp ) throw ( FormatError ); + bool ReadAndDecompressRLEFile( FILE* fp ); + bool ReadAndDecompressJPEGFile( 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 ComputeDecompressedImageDataSize(); + void AllocateRGB(); + void AllocateDecompressed(); +public: +// In progress + bool ReadAndDecompressPixelData( FILE* fp ); + void Squeeze(); }; +} // end namespace gdcm //----------------------------------------------------------------------------- #endif