]> Creatis software - gdcm.git/blob - src/gdcmPixelConvert.h
* CLEANUP_ROUND (9) for gdcmPixelConvert
[gdcm.git] / src / gdcmPixelConvert.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmPixelConvert.h,v $
5   Language:  C++
6   Date:      $Date: 2004/10/08 17:02:53 $
7   Version:   $Revision: 1.4 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18
19
20 #ifndef GDCMPIXELCONVERT_H
21 #define GDCMPIXELCONVERTL_H
22
23 #include "gdcmCommon.h"
24 #include "gdcmRLEFramesInfo.h"
25 #include "gdcmException.h"
26
27 /*
28  * \brief Utility container for gathering the various forms the pixel data
29  *        migth take during the user demanded processes.
30  */
31 class GDCM_EXPORT gdcmPixelConvert {
32 friend class gdcmFile;
33    /// Pixel data represented as RGB after color interpretation
34    uint8_t* RGB;
35    size_t   RGBSize;          //aka ImageDataSize
36    /// Pixel data after decompression and bit/byte rearrangement.
37    uint8_t* Uncompressed;
38    size_t   UncompressedSize;
39 public:
40    gdcmPixelConvert();
41    ~gdcmPixelConvert();
42
43    uint8_t* GetRGB() { return RGB; }
44    void     SetRGBSize( size_t size ) { RGBSize = size; }
45    size_t   GetRGBSize() { return RGBSize; }
46    void     AllocateRGB();
47
48    uint8_t* GetUncompressed() { return Uncompressed; }
49    void     SetUncompressedSize( size_t size ) { UncompressedSize = size; }
50    size_t   GetUncompressedSize() { return UncompressedSize; }
51    void     AllocateUncompressed();
52
53    void Squeeze();
54 //////////////////////////////////////////////////////////
55 // In progress
56 bool ReadAndUncompress12Bits( FILE* filePointer,
57                               size_t uncompressedSize,
58                               size_t PixelNumber );
59 bool ReadUncompressed( FILE* filePointer,
60                        size_t uncompressedSize,
61                        size_t expectedSize );
62 bool ConvertGrayAndLutToRGB( uint8_t *lutRGBA );
63 bool ReadAndUncompressRLE8Bits(FILE* fp, size_t uncompressedSize );
64
65    static bool UncompressRLE16BitsFromRLE8Bits(
66                   int XSize,
67                   int YSize,
68                   int NumberOfFrames,
69                   uint8_t* fixMemUncompressed );
70    static bool ReadAndUncompressRLEFragment(
71                   uint8_t* decodedZone,
72                   long fragmentSize,
73                   long uncompressedSegmentSize,
74                   FILE* fp );
75    static bool gdcm_read_RLE_file(
76                   void* image_buffer,
77                   int XSize,
78                   int YSize,
79                   int ZSize,
80                   int BitsAllocated,
81                   gdcmRLEFramesInfo* RLEInfo,
82                   FILE* fp );
83    static void ConvertDecompress12BitsTo16Bits(
84                   uint8_t* pixelZone,
85                   int sizeX,
86                   int sizeY,
87                   FILE* filePtr) throw ( gdcmFormatError );
88    static void SwapZone(void* im, int swap, int lgr, int nb);
89    static void ConvertReorderEndianity(
90                   uint8_t* pixelZone,
91                   size_t imageDataSize,
92                   int numberBitsStored,
93                   int numberBitsAllocated,
94                   int swapCode,
95                   bool signedPixel );
96 };
97
98 //-----------------------------------------------------------------------------
99 #endif