GDCM 3.0.24
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
30namespace gdcm
31{
32
39{
40public:
42 ~Bitmap() override;
43 void Print(std::ostream &) const override;
44
45 virtual bool AreOverlaysInPixelData() const { return false; }
46 virtual bool UnusedBitsPresentInPixelData() const { return false; }
47
49 unsigned int GetNumberOfDimensions() const;
50 void SetNumberOfDimensions(unsigned int dim);
51
53 unsigned int GetPlanarConfiguration() const;
55 void SetPlanarConfiguration(unsigned int pc);
56
58 bool GetNeedByteSwap() const
59 {
60 return NeedByteSwap;
61 }
62 void SetNeedByteSwap(bool b)
63 {
64 NeedByteSwap = b;
65 }
66
67
70 TS = ts;
71 }
73 return TS;
74 }
76 void SetDataElement(DataElement const &de) {
77 PixelData = de;
78 }
79 const DataElement& GetDataElement() const { return PixelData; }
80 DataElement& GetDataElement() { return PixelData; }
81
83 void SetLUT(LookupTable const &lut)
84 {
85 LUT = SmartPointer<LookupTable>( const_cast<LookupTable*>(&lut) );
86 }
87 const LookupTable &GetLUT() const
88 {
89 return *LUT;
90 }
92 {
93 return *LUT;
94 }
95
97 const unsigned int *GetDimensions() const;
98 unsigned int GetDimension(unsigned int idx) const;
99
100 void SetColumns(unsigned int col) { SetDimension(0,col); }
101 unsigned int GetColumns() const { return GetDimension(0); }
102 void SetRows(unsigned int rows) { SetDimension(1,rows); }
103 unsigned int GetRows() const { return GetDimension(1); }
104 void SetDimensions(const unsigned int dims[3]);
105 void SetDimension(unsigned int idx, unsigned int dim);
108 {
109 return PF;
110 }
112 {
113 return PF;
114 }
116 {
117 PF = pf;
118 PF.Validate();
119 }
120
124
125 bool IsEmpty() const { return Dimensions.empty(); }
126 void Clear();
127
131 unsigned long GetBufferLength() const;
132
134 bool GetBuffer(char *buffer) const;
135
137 bool IsLossy() const;
138
140 void SetLossyFlag(bool f) { LossyFlag = f; }
141
142protected:
143 bool TryRAWCodec(char *buffer, bool &lossyflag) const;
144 bool TryJPEGCodec(char *buffer, bool &lossyflag) const;
145 bool TryPVRGCodec(char *buffer, bool &lossyflag) const;
146 bool TryKAKADUCodec(char *buffer, bool &lossyflag) const;
147 bool TryJPEGLSCodec(char *buffer, bool &lossyflag) const;
148 bool TryJPEG2000Codec(char *buffer, bool &lossyflag) const;
149 bool TryRLECodec(char *buffer, bool &lossyflag) const;
150
151 bool TryJPEGCodec2(std::ostream &os) const;
152 bool TryJPEG2000Codec2(std::ostream &os) const;
153
154 bool GetBuffer2(std::ostream &os) const;
155
156 friend class PixmapReader;
158 // Function to compute the lossy flag based only on the image buffer.
159 // Watch out that image can be lossy but in implicit little endian format...
161
162//private:
163protected:
165 unsigned int NumberOfDimensions;
167 PixelFormat PF; // SamplesPerPixel, BitsAllocated, BitsStored, HighBit, PixelRepresentation
169 // Mind dump: unsigned int is required here, since we are reading (0028,0008) Number Of Frames
170 // which is VR::IS, so I cannot simply assumed that unsigned short is enough... :(
171 std::vector<unsigned int> Dimensions; // Col/Row
172 DataElement PixelData; // copied from 7fe0,0010
173
176 // I believe the following 3 ivars can be derived from TS ...
177 bool NeedByteSwap; // FIXME: remove me
179
180private:
181 bool GetBufferInternal(char *buffer, bool &lossyflag) const;
182};
183
184} // end namespace gdcm
185
186#endif //GDCMBITMAP_H
Bitmap class.
Definition gdcmBitmap.h:39
void SetPlanarConfiguration(unsigned int pc)
PixelFormat & GetPixelFormat()
Definition gdcmBitmap.h:111
bool IsLossy() const
Return whether or not the image was compressed using a lossy compressor or not.
bool TryKAKADUCodec(char *buffer, bool &lossyflag) const
const LookupTable & GetLUT() const
Definition gdcmBitmap.h:87
void SetNumberOfDimensions(unsigned int dim)
LUTPtr LUT
Definition gdcmBitmap.h:175
bool IsEmpty() const
Definition gdcmBitmap.h:125
void SetLUT(LookupTable const &lut)
Set/Get LUT.
Definition gdcmBitmap.h:83
unsigned long GetBufferLength() const
void SetDimensions(const unsigned int dims[3])
std::vector< unsigned int > Dimensions
Definition gdcmBitmap.h:171
PixelFormat PF
Definition gdcmBitmap.h:167
void SetRows(unsigned int rows)
Definition gdcmBitmap.h:102
void SetNeedByteSwap(bool b)
Definition gdcmBitmap.h:62
void SetDataElement(DataElement const &de)
Definition gdcmBitmap.h:76
void SetColumns(unsigned int col)
Definition gdcmBitmap.h:100
bool TryPVRGCodec(char *buffer, bool &lossyflag) const
void SetDimension(unsigned int idx, unsigned int dim)
bool TryJPEG2000Codec(char *buffer, bool &lossyflag) const
bool ComputeLossyFlag()
unsigned int GetPlanarConfiguration() const
return the planar configuration
virtual bool UnusedBitsPresentInPixelData() const
Definition gdcmBitmap.h:46
const PixelFormat & GetPixelFormat() const
Get/Set PixelFormat.
Definition gdcmBitmap.h:107
TransferSyntax TS
Definition gdcmBitmap.h:166
const PhotometricInterpretation & GetPhotometricInterpretation() const
return the photometric interpretation
void SetTransferSyntax(TransferSyntax const &ts)
Transfer syntax.
Definition gdcmBitmap.h:69
bool TryJPEGLSCodec(char *buffer, bool &lossyflag) const
bool GetBuffer(char *buffer) const
Access the raw data.
const DataElement & GetDataElement() const
Definition gdcmBitmap.h:79
void SetPhotometricInterpretation(PhotometricInterpretation const &pi)
void SetLossyFlag(bool f)
Specifically set that the image was compressed using a lossy compression mechanism.
Definition gdcmBitmap.h:140
bool NeedByteSwap
Definition gdcmBitmap.h:177
bool TryJPEGCodec(char *buffer, bool &lossyflag) const
void Print(std::ostream &) const override
bool TryRLECodec(char *buffer, bool &lossyflag) const
bool LossyFlag
Definition gdcmBitmap.h:178
unsigned int GetDimension(unsigned int idx) const
bool IsTransferSyntaxCompatible(TransferSyntax const &ts) const
virtual bool AreOverlaysInPixelData() const
Definition gdcmBitmap.h:45
bool TryRAWCodec(char *buffer, bool &lossyflag) const
bool TryJPEGCodec2(std::ostream &os) const
const unsigned int * GetDimensions() const
Return the dimension of the pixel data, first dimension (x), then 2nd (y), then 3rd (z)....
bool TryJPEG2000Codec2(std::ostream &os) const
unsigned int GetRows() const
Definition gdcmBitmap.h:103
LookupTable & GetLUT()
Definition gdcmBitmap.h:91
bool GetNeedByteSwap() const
INTERNAL do not use.
Definition gdcmBitmap.h:58
unsigned int GetNumberOfDimensions() const
Return the number of dimension of the pixel data bytes; for example 2 for a 2D matrices of values.
DataElement & GetDataElement()
Definition gdcmBitmap.h:80
unsigned int PlanarConfiguration
Definition gdcmBitmap.h:164
PhotometricInterpretation PI
Definition gdcmBitmap.h:168
SmartPointer< LookupTable > LUTPtr
Definition gdcmBitmap.h:174
void SetPixelFormat(PixelFormat const &pf)
Definition gdcmBitmap.h:115
unsigned int GetColumns() const
Definition gdcmBitmap.h:101
const TransferSyntax & GetTransferSyntax() const
Definition gdcmBitmap.h:72
~Bitmap() override
bool GetBuffer2(std::ostream &os) const
unsigned int NumberOfDimensions
Definition gdcmBitmap.h:165
DataElement PixelData
Definition gdcmBitmap.h:172
Class to represent a Data Element either Implicit or Explicit.
Definition gdcmDataElement.h:59
ImageChangeTransferSyntax class.
Definition gdcmImageChangeTransferSyntax.h:40
LookupTable class.
Definition gdcmLookupTable.h:30
Object.
Definition gdcmObject.h:37
Class to represent an PhotometricInterpretation.
Definition gdcmPhotometricInterpretation.h:29
PixelFormat.
Definition gdcmPixelFormat.h:46
bool Validate()
When image with 24/24/23 was read, need to validate.
PixmapReader.
Definition gdcmPixmapReader.h:40
Class for Smart Pointer.
Definition gdcmSmartPointer.h:40
Class to manipulate Transfer Syntax.
Definition gdcmTransferSyntax.h:40
#define GDCM_EXPORT
Definition gdcmWin32.h:34
Definition gdcmASN1.h:21