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