GDCM 2.2.1

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

gdcmBitmap.h
Go to the documentation of this file.
1 /*=========================================================================
2
3 Program: GDCM (Grassroots DICOM). A DICOM library
4
5 Copyright (c) 2006-2011 Mathieu Malaterre
6 All rights reserved.
7 See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
8
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the above copyright notice for more information.
12
13 =========================================================================*/
14 #ifndef GDCMBITMAP_H
15 #define GDCMBITMAP_H
16
17 #include "gdcmObject.h"
18 #include "gdcmCurve.h"
19 #include "gdcmDataElement.h"
20 //#include "gdcmIconImage.h"
21 #include "gdcmLookupTable.h"
22 #include "gdcmOverlay.h"
23 #include "gdcmPhotometricInterpretation.h"
24 #include "gdcmPixelFormat.h"
25 #include "gdcmSmartPointer.h"
26 #include "gdcmTransferSyntax.h"
27
28 #include <vector>
29
30 namespace gdcm
31 {
32
38 class GDCM_EXPORT Bitmap : public Object
39 {
40 public:
41 Bitmap();
42 ~Bitmap();
43 void Print(std::ostream &) const;
44
45 virtual bool AreOverlaysInPixelData() const { return false; }
46
48 unsigned int GetNumberOfDimensions() const;
49 void SetNumberOfDimensions(unsigned int dim);
50
52 unsigned int GetPlanarConfiguration() const;
54 void SetPlanarConfiguration(unsigned int pc);
55
56 bool GetNeedByteSwap() const
57 {
58 return NeedByteSwap;
59 }
60 void SetNeedByteSwap(bool b)
61 {
62 NeedByteSwap = b;
63 }
64
65
67 void SetTransferSyntax(TransferSyntax const &ts) {
68 TS = ts;
69 }
70 const TransferSyntax &GetTransferSyntax() const {
71 return TS;
72 }
73 bool IsTransferSyntaxCompatible( TransferSyntax const & ts ) const;
74 void SetDataElement(DataElement const &de) {
75 PixelData = de;
76 }
77 const DataElement& GetDataElement() const { return PixelData; }
78 DataElement& GetDataElement() { return PixelData; }
79
81 void SetLUT(LookupTable const &lut)
82 {
83 LUT = SmartPointer<LookupTable>( const_cast< LookupTable*>(&lut) );
84 }
85 const LookupTable &GetLUT() const
86 {
87 return *LUT;
88 }
89 LookupTable &GetLUT()
90 {
91 return *LUT;
92 }
93
95 const unsigned int *GetDimensions() const;
96 unsigned int GetDimension(unsigned int idx) const;
97
98 void SetColumns(unsigned int col) { SetDimension(0,col); }
99 unsigned int GetColumns() const { return GetDimension(0); }
100 void SetRows(unsigned int rows) { SetDimension(1,rows); }
101 unsigned int GetRows() const { return GetDimension(1); }
102 void SetDimensions(const unsigned int dims[3]);
103 void SetDimension(unsigned int idx, unsigned int dim);
105 const PixelFormat &GetPixelFormat() const
106 {
107 return PF;
108 }
109 PixelFormat &GetPixelFormat()
110 {
111 return PF;
112 }
113 void SetPixelFormat(PixelFormat const &pf)
114 {
115 PF = pf;
116 PF.Validate();
117 }
118
120 const PhotometricInterpretation &GetPhotometricInterpretation() const;
121 void SetPhotometricInterpretation(PhotometricInterpretation const &pi);
122
123 bool IsEmpty() const { return Dimensions.size() == 0; }
124 void Clear();
125
129 unsigned long GetBufferLength() const;
130
132 bool GetBuffer(char *buffer) const;
133
135 bool IsLossy() const;
136
138 void SetLossyFlag(bool f) { LossyFlag = f; }
139
140 protected:
141 bool TryRAWCodec(char *buffer, bool &lossyflag) const;
142 bool TryJPEGCodec(char *buffer, bool &lossyflag) const;
143 bool TryPVRGCodec(char *buffer, bool &lossyflag) const;
144 bool TryKAKADUCodec(char *buffer, bool &lossyflag) const;
145 bool TryJPEGLSCodec(char *buffer, bool &lossyflag) const;
146 bool TryJPEG2000Codec(char *buffer, bool &lossyflag) const;
147 bool TryRLECodec(char *buffer, bool &lossyflag) const;
148
149 bool TryJPEGCodec2(std::ostream &os) const;
150 bool TryJPEG2000Codec2(std::ostream &os) const;
151
152 bool GetBuffer2(std::ostream &os) const;
153
154 friend class PixmapReader;
155 friend class ImageChangeTransferSyntax;
156 // Function to compute the lossy flag based only on the image buffer.
157 // Watch out that image can be lossy but in implicit little endian format...
158 bool ComputeLossyFlag();
159
160 //private:
161 protected:
162 unsigned int PlanarConfiguration;
163 unsigned int NumberOfDimensions;
164 TransferSyntax TS;
165 PixelFormat PF; // SamplesPerPixel, BitsAllocated, BitsStored, HighBit, PixelRepresentation
166 PhotometricInterpretation PI;
167 // Mind dump: unsigned int is required here, since we are reading (0028,0008) Number Of Frames
168 // which is VR::IS, so I cannot simply assumed that unsigned short is enough... :(
169 std::vector<unsigned int> Dimensions; // Col/Row
170 DataElement PixelData; // copied from 7fe0,0010
171
172 typedef SmartPointer<LookupTable> LUTPtr;
173 LUTPtr LUT;
174 // I believe the following 3 ivars can be derived from TS ...
175 bool NeedByteSwap;
176 bool LossyFlag;
177
178 private:
179 bool GetBufferInternal(char *buffer, bool &lossyflag) const;
180 };
181
182 } // end namespace gdcm
183
184 #endif //GDCMBITMAP_H