]> Creatis software - gdcm.git/blob - src/gdcmPixelConvert.h
ENH: Adding 'gdcm' namespace. Be nice with me this was a ~13000 lines patch. Also...
[gdcm.git] / src / gdcmPixelConvert.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmPixelConvert.h,v $
5   Language:  C++
6   Date:      $Date: 2004/10/12 04:35:47 $
7   Version:   $Revision: 1.6 $
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 "gdcmJPEGFragmentsInfo.h"
26 #include "gdcmException.h"
27
28 namespace gdcm 
29 {
30
31 /*
32  * \brief Utility container for gathering the various forms the pixel data
33  *        migth take during the user demanded processes.
34  */
35 class GDCM_EXPORT PixelConvert {
36 friend class File;
37    /// Pixel data represented as RGB after color interpretation
38    uint8_t* RGB;
39    size_t   RGBSize;          //aka ImageDataSize
40    /// Pixel data after decompression and bit/byte rearrangement.
41    uint8_t* Uncompressed;
42    size_t   UncompressedSize;
43 public:
44    PixelConvert();
45    ~PixelConvert();
46
47    uint8_t* GetRGB() { return RGB; }
48    void     SetRGBSize( size_t size ) { RGBSize = size; }
49    size_t   GetRGBSize() { return RGBSize; }
50    void     AllocateRGB();
51
52    uint8_t* GetUncompressed() { return Uncompressed; }
53    void     SetUncompressedSize( size_t size ) { UncompressedSize = size; }
54    size_t   GetUncompressedSize() { return UncompressedSize; }
55    void     AllocateUncompressed();
56
57    void Squeeze();
58 //////////////////////////////////////////////////////////
59 // In progress
60    static bool UncompressRLE16BitsFromRLE8Bits(
61                   int XSize,
62                   int YSize,
63                   int NumberOfFrames,
64                   uint8_t* fixMemUncompressed );
65    static bool ReadAndUncompressRLEFragment(
66                   uint8_t* decodedZone,
67                   long fragmentSize,
68                   long uncompressedSegmentSize,
69                   FILE* fp );
70    static bool ReadAndDecompressRLEFile(
71                   void* image_buffer,
72                   int XSize,
73                   int YSize,
74                   int ZSize,
75                   int BitsAllocated,
76                   RLEFramesInfo* RLEInfo,
77                   FILE* fp );
78    static void ConvertDecompress12BitsTo16Bits(
79                   uint8_t* pixelZone,
80                   int sizeX,
81                   int sizeY,
82                   FILE* filePtr) throw ( FormatError );
83    static void SwapZone(void* im, int swap, int lgr, int nb);
84    static void ConvertReorderEndianity(
85                   uint8_t* pixelZone,
86                   size_t imageDataSize,
87                   int numberBitsStored,
88                   int numberBitsAllocated,
89                   int swapCode,
90                   bool signedPixel );
91    static bool ReadAndDecompressJPEGFile(
92                   uint8_t* destination,
93                   int XSize,
94                   int YSize,
95                   int BitsAllocated,
96                   int BitsStored,
97                   int SamplesPerPixel,
98                   int PixelSize,
99                   bool isJPEG2000,
100                   bool isJPEGLossless,
101                   JPEGFragmentsInfo* JPEGInfo,
102                   FILE* fp );
103    static bool PixelConvert::ConvertReArrangeBits(
104                   uint8_t* pixelZone,
105                   size_t imageDataSize,
106                   int numberBitsStored,
107                   int numberBitsAllocated,
108                   int highBitPosition ) throw ( FormatError );
109
110
111 };
112 } // end namespace gdcm
113 //-----------------------------------------------------------------------------
114 #endif