GDCM: gdcmBitmap.h Source File

GDCM 3.2.10

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
30namespace gdcm
31{
32
38 class GDCM_EXPORT Bitmap : public Object
39{
40public:
41 Bitmap();
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
69 void SetTransferSyntax(TransferSyntax const &ts) {
70 TS = ts;
71 }
72 const TransferSyntax &GetTransferSyntax() const {
73 return TS;
74 }
75 bool IsTransferSyntaxCompatible( TransferSyntax const & ts ) const;
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 }
91 LookupTable &GetLUT()
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);
107 const PixelFormat &GetPixelFormat() const
108 {
109 return PF;
110 }
111 PixelFormat &GetPixelFormat()
112 {
113 return PF;
114 }
115 void SetPixelFormat(PixelFormat const &pf)
116 {
117 PF = pf;
118 PF.Validate();
119 }
120
122 const PhotometricInterpretation &GetPhotometricInterpretation() const;
123 void SetPhotometricInterpretation(PhotometricInterpretation const &pi);
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;
157 friend class ImageChangeTransferSyntax;
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...
160 bool ComputeLossyFlag();
161
162//private:
163protected:
164 unsigned int PlanarConfiguration;
165 unsigned int NumberOfDimensions;
166 TransferSyntax TS;
167 PixelFormat PF; // SamplesPerPixel, BitsAllocated, BitsStored, HighBit, PixelRepresentation
168 PhotometricInterpretation PI;
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
174 typedef SmartPointer<LookupTable> LUTPtr;
175 LUTPtr LUT;
176 // I believe the following 3 ivars can be derived from TS ...
177 bool NeedByteSwap; // FIXME: remove me
178 bool LossyFlag;
179
180private:
181 bool GetBufferInternal(char *buffer, bool &lossyflag) const;
182};
183
184} // end namespace gdcm
185
186#endif //GDCMBITMAP_H
gdcm::Bitmap::SetPlanarConfiguration
void SetPlanarConfiguration(unsigned int pc)
gdcm::Bitmap::GetPixelFormat
PixelFormat & GetPixelFormat()
Definition gdcmBitmap.h:111
gdcm::Bitmap::IsLossy
bool IsLossy() const
Return whether or not the image was compressed using a lossy compressor or not.
gdcm::Bitmap::TryKAKADUCodec
bool TryKAKADUCodec(char *buffer, bool &lossyflag) const
gdcm::Bitmap::GetLUT
const LookupTable & GetLUT() const
Definition gdcmBitmap.h:87
gdcm::Bitmap::SetNumberOfDimensions
void SetNumberOfDimensions(unsigned int dim)
gdcm::Bitmap::LUT
LUTPtr LUT
Definition gdcmBitmap.h:175
gdcm::Bitmap::IsEmpty
bool IsEmpty() const
Definition gdcmBitmap.h:125
gdcm::Bitmap::SetLUT
void SetLUT(LookupTable const &lut)
Set/Get LUT.
Definition gdcmBitmap.h:83
gdcm::Bitmap::GetBufferLength
unsigned long GetBufferLength() const
gdcm::Bitmap::SetDimensions
void SetDimensions(const unsigned int dims[3])
gdcm::Bitmap::Dimensions
std::vector< unsigned int > Dimensions
Definition gdcmBitmap.h:171
gdcm::Bitmap::PF
PixelFormat PF
Definition gdcmBitmap.h:167
gdcm::Bitmap::SetRows
void SetRows(unsigned int rows)
Definition gdcmBitmap.h:102
gdcm::Bitmap::SetNeedByteSwap
void SetNeedByteSwap(bool b)
Definition gdcmBitmap.h:62
gdcm::Bitmap::SetDataElement
void SetDataElement(DataElement const &de)
Definition gdcmBitmap.h:76
gdcm::Bitmap::SetColumns
void SetColumns(unsigned int col)
Definition gdcmBitmap.h:100
gdcm::Bitmap::TryPVRGCodec
bool TryPVRGCodec(char *buffer, bool &lossyflag) const
gdcm::Bitmap::SetDimension
void SetDimension(unsigned int idx, unsigned int dim)
gdcm::Bitmap::TryJPEG2000Codec
bool TryJPEG2000Codec(char *buffer, bool &lossyflag) const
gdcm::Bitmap::ComputeLossyFlag
bool ComputeLossyFlag()
gdcm::Bitmap::GetPlanarConfiguration
unsigned int GetPlanarConfiguration() const
return the planar configuration
gdcm::Bitmap::UnusedBitsPresentInPixelData
virtual bool UnusedBitsPresentInPixelData() const
Definition gdcmBitmap.h:46
gdcm::Bitmap::GetPixelFormat
const PixelFormat & GetPixelFormat() const
Get/Set PixelFormat.
Definition gdcmBitmap.h:107
gdcm::Bitmap::TS
TransferSyntax TS
Definition gdcmBitmap.h:166
gdcm::Bitmap::GetPhotometricInterpretation
const PhotometricInterpretation & GetPhotometricInterpretation() const
return the photometric interpretation
gdcm::Bitmap::SetTransferSyntax
void SetTransferSyntax(TransferSyntax const &ts)
Transfer syntax.
Definition gdcmBitmap.h:69
gdcm::Bitmap::TryJPEGLSCodec
bool TryJPEGLSCodec(char *buffer, bool &lossyflag) const
gdcm::Bitmap::GetBuffer
bool GetBuffer(char *buffer) const
Access the raw data.
gdcm::Bitmap::GetDataElement
const DataElement & GetDataElement() const
Definition gdcmBitmap.h:79
gdcm::Bitmap::PixmapReader
friend class PixmapReader
Definition gdcmBitmap.h:156
gdcm::Bitmap::SetPhotometricInterpretation
void SetPhotometricInterpretation(PhotometricInterpretation const &pi)
gdcm::Bitmap::SetLossyFlag
void SetLossyFlag(bool f)
Specifically set that the image was compressed using a lossy compression mechanism.
Definition gdcmBitmap.h:140
gdcm::Bitmap::NeedByteSwap
bool NeedByteSwap
Definition gdcmBitmap.h:177
gdcm::Bitmap::TryJPEGCodec
bool TryJPEGCodec(char *buffer, bool &lossyflag) const
gdcm::Bitmap::Print
void Print(std::ostream &) const override
gdcm::Bitmap::TryRLECodec
bool TryRLECodec(char *buffer, bool &lossyflag) const
gdcm::Bitmap::LossyFlag
bool LossyFlag
Definition gdcmBitmap.h:178
gdcm::Bitmap::ImageChangeTransferSyntax
friend class ImageChangeTransferSyntax
Definition gdcmBitmap.h:157
gdcm::Bitmap::GetDimension
unsigned int GetDimension(unsigned int idx) const
gdcm::Bitmap::IsTransferSyntaxCompatible
bool IsTransferSyntaxCompatible(TransferSyntax const &ts) const
gdcm::Bitmap::AreOverlaysInPixelData
virtual bool AreOverlaysInPixelData() const
Definition gdcmBitmap.h:45
gdcm::Bitmap::TryRAWCodec
bool TryRAWCodec(char *buffer, bool &lossyflag) const
gdcm::Bitmap::TryJPEGCodec2
bool TryJPEGCodec2(std::ostream &os) const
gdcm::Bitmap::GetDimensions
const unsigned int * GetDimensions() const
Return the dimension of the pixel data, first dimension (x), then 2nd (y), then 3rd (z)....
gdcm::Bitmap::TryJPEG2000Codec2
bool TryJPEG2000Codec2(std::ostream &os) const
gdcm::Bitmap::GetRows
unsigned int GetRows() const
Definition gdcmBitmap.h:103
gdcm::Bitmap::GetLUT
LookupTable & GetLUT()
Definition gdcmBitmap.h:91
gdcm::Bitmap::GetNeedByteSwap
bool GetNeedByteSwap() const
INTERNAL do not use.
Definition gdcmBitmap.h:58
gdcm::Bitmap::GetNumberOfDimensions
unsigned int GetNumberOfDimensions() const
Return the number of dimension of the pixel data bytes; for example 2 for a 2D matrices of values.
gdcm::Bitmap::GetDataElement
DataElement & GetDataElement()
Definition gdcmBitmap.h:80
gdcm::Bitmap::PlanarConfiguration
unsigned int PlanarConfiguration
Definition gdcmBitmap.h:164
gdcm::Bitmap::PI
PhotometricInterpretation PI
Definition gdcmBitmap.h:168
gdcm::Bitmap::LUTPtr
SmartPointer< LookupTable > LUTPtr
Definition gdcmBitmap.h:174
gdcm::Bitmap::SetPixelFormat
void SetPixelFormat(PixelFormat const &pf)
Definition gdcmBitmap.h:115
gdcm::Bitmap::GetColumns
unsigned int GetColumns() const
Definition gdcmBitmap.h:101
gdcm::Bitmap::GetTransferSyntax
const TransferSyntax & GetTransferSyntax() const
Definition gdcmBitmap.h:72
gdcm::Bitmap::~Bitmap
~Bitmap() override
gdcm::Bitmap::Clear
void Clear()
gdcm::Bitmap::GetBuffer2
bool GetBuffer2(std::ostream &os) const
gdcm::Bitmap::Bitmap
Bitmap()
gdcm::Bitmap::NumberOfDimensions
unsigned int NumberOfDimensions
Definition gdcmBitmap.h:165
gdcm::Bitmap::PixelData
DataElement PixelData
Definition gdcmBitmap.h:172
gdcm::DataElement
Class to represent a Data Element either Implicit or Explicit.
Definition gdcmDataElement.h:59
gdcm::LookupTable
LookupTable class.
Definition gdcmLookupTable.h:30
gdcm::Object::Object
Object()
Definition gdcmObject.h:42
gdcm::Object::SmartPointer
friend class SmartPointer
Definition gdcmObject.h:38
gdcm::PhotometricInterpretation
Class to represent an PhotometricInterpretation.
Definition gdcmPhotometricInterpretation.h:29
gdcm::PixelFormat
PixelFormat.
Definition gdcmPixelFormat.h:46
gdcm::TransferSyntax
Class to manipulate Transfer Syntax.
Definition gdcmTransferSyntax.h:40
gdcmCurve.h
gdcmDataElement.h
gdcmLookupTable.h
gdcmObject.h
gdcmOverlay.h
gdcmPhotometricInterpretation.h
gdcmPixelFormat.h
gdcmSmartPointer.h
gdcmTransferSyntax.h
GDCM_EXPORT
#define GDCM_EXPORT
Definition gdcmWin32.h:34
gdcm
Definition gdcmASN1.h:21