GDCM  2.4.5
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"
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 
68  TS = ts;
69  }
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  }
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);
106  {
107  return PF;
108  }
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;
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;
165  PixelFormat PF; // SamplesPerPixel, BitsAllocated, BitsStored, HighBit, PixelRepresentation
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 
173  LUTPtr LUT;
174  // I believe the following 3 ivars can be derived from TS ...
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
LookupTable class.
Definition: gdcmLookupTable.h:29
PixelFormat & GetPixelFormat()
Definition: gdcmBitmap.h:109
void SetPixelFormat(PixelFormat const &pf)
Definition: gdcmBitmap.h:113
PixelFormat PF
Definition: gdcmBitmap.h:165
bool IsEmpty() const
Definition: gdcmBitmap.h:123
void SetNeedByteSwap(bool b)
Definition: gdcmBitmap.h:60
TransferSyntax TS
Definition: gdcmBitmap.h:164
virtual bool AreOverlaysInPixelData() const
Definition: gdcmBitmap.h:45
void SetColumns(unsigned int col)
Definition: gdcmBitmap.h:98
bool NeedByteSwap
Definition: gdcmBitmap.h:175
#define GDCM_EXPORT
Definition: gdcmWin32.h:34
ImageChangeTransferSyntax class Class to change the transfer syntax of an input DICOM.
Definition: gdcmImageChangeTransferSyntax.h:39
LUTPtr LUT
Definition: gdcmBitmap.h:173
Bitmap class A bitmap based image. Used as parent for both IconImage and the main Pixel Data Image It...
Definition: gdcmBitmap.h:38
void SetLUT(LookupTable const &lut)
Set/Get LUT.
Definition: gdcmBitmap.h:81
const DataElement & GetDataElement() const
Definition: gdcmBitmap.h:77
Object.
Definition: gdcmObject.h:36
void SetDataElement(DataElement const &de)
Definition: gdcmBitmap.h:74
Class to represent a Data Element either Implicit or Explicit.
Definition: gdcmDataElement.h:58
unsigned int GetRows() const
Definition: gdcmBitmap.h:101
PhotometricInterpretation PI
Definition: gdcmBitmap.h:166
void SetLossyFlag(bool f)
Specifically set that the image was compressed using a lossy compression mechanism.
Definition: gdcmBitmap.h:138
unsigned int NumberOfDimensions
Definition: gdcmBitmap.h:163
bool LossyFlag
Definition: gdcmBitmap.h:176
Class to manipulate Transfer Syntax.
Definition: gdcmTransferSyntax.h:39
const PixelFormat & GetPixelFormat() const
Get/Set PixelFormat.
Definition: gdcmBitmap.h:105
const TransferSyntax & GetTransferSyntax() const
Definition: gdcmBitmap.h:70
SmartPointer< LookupTable > LUTPtr
Definition: gdcmBitmap.h:172
bool GetNeedByteSwap() const
Definition: gdcmBitmap.h:56
LookupTable & GetLUT()
Definition: gdcmBitmap.h:89
PixmapReader.
Definition: gdcmPixmapReader.h:39
DataElement & GetDataElement()
Definition: gdcmBitmap.h:78
std::vector< unsigned int > Dimensions
Definition: gdcmBitmap.h:169
Class to represent an PhotometricInterpretation.
Definition: gdcmPhotometricInterpretation.h:28
bool Validate()
When image with 24/24/23 was read, need to validate.
void SetTransferSyntax(TransferSyntax const &ts)
Transfer syntax.
Definition: gdcmBitmap.h:67
unsigned int GetColumns() const
Definition: gdcmBitmap.h:99
const LookupTable & GetLUT() const
Definition: gdcmBitmap.h:85
unsigned int PlanarConfiguration
Definition: gdcmBitmap.h:162
Definition: gdcmASN1.h:20
PixelFormat.
Definition: gdcmPixelFormat.h:45
Definition: gdcmTerminal.h:52
void SetRows(unsigned int rows)
Definition: gdcmBitmap.h:100
DataElement PixelData
Definition: gdcmBitmap.h:170

Generated on Fri Sep 25 2015 17:58:22 for GDCM by doxygen 1.8.9.1
SourceForge.net Logo