X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmPixelConvert.h;h=74a01d1e0a3625e8dc4fd315d546bfd3c0aa1a37;hb=5bf7c51796867388334836847a6874640bc83f89;hp=02f11f3b3db41ae1acfddd15442be418ec2c9803;hpb=15424662ec90f5a5071bcf32e7f6dc09cead024d;p=gdcm.git diff --git a/src/gdcmPixelConvert.h b/src/gdcmPixelConvert.h index 02f11f3b..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/08 17:02:53 $ - Version: $Revision: 1.4 $ + 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 @@ -22,78 +22,116 @@ #include "gdcmCommon.h" #include "gdcmRLEFramesInfo.h" +#include "gdcmJPEGFragmentsInfo.h" #include "gdcmException.h" +#include "gdcmHeader.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; - /// 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; +class GDCM_EXPORT PixelConvert { public: - gdcmPixelConvert(); - ~gdcmPixelConvert(); + PixelConvert(); + ~PixelConvert(); + //// Getter accessors: uint8_t* GetRGB() { return RGB; } - void SetRGBSize( size_t size ) { RGBSize = size; } size_t GetRGBSize() { return RGBSize; } - void AllocateRGB(); + uint8_t* GetDecompressed() { return Decompressed; } + size_t GetDecompressedSize() { return DecompressedSize; } + uint8_t* GetLutRGBA() { return LutRGBA; } - uint8_t* GetUncompressed() { return Uncompressed; } - void SetUncompressedSize( size_t size ) { UncompressedSize = size; } - size_t GetUncompressedSize() { return UncompressedSize; } - void AllocateUncompressed(); + //// Predicates: + bool IsDecompressedRGB(); + + void Print( std::string indent = "", std::ostream &os = std::cout ); - 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, + 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 uncompressedSegmentSize, + long decompressedSegmentSize, FILE* fp ); - static bool gdcm_read_RLE_file( - void* image_buffer, - int XSize, - int YSize, - int ZSize, - int BitsAllocated, - gdcmRLEFramesInfo* RLEInfo, - FILE* fp ); - static void ConvertDecompress12BitsTo16Bits( - uint8_t* pixelZone, - int sizeX, - int sizeY, - FILE* filePtr) throw ( gdcmFormatError ); - static void SwapZone(void* im, int swap, int lgr, int nb); - static void ConvertReorderEndianity( - uint8_t* pixelZone, - size_t imageDataSize, - int numberBitsStored, - int numberBitsAllocated, - int swapCode, - bool signedPixel ); + 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 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; + + 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 IsDecompressed; + bool IsJPEG2000; + bool IsJPEGLossless; + bool IsRLELossless; + + RLEFramesInfo* RLEInfo; + JPEGFragmentsInfo* JPEGInfo; + + // For handling color stage + int PlanarConfiguration; + 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; + }; +} // end namespace gdcm //----------------------------------------------------------------------------- #endif