gdcmBitmap.h
Go to the documentation of this file.
/*=========================================================================
Program: GDCM (Grassroots DICOM). A DICOM library
Copyright (c) 2006-2011 Mathieu Malaterre
All rights reserved.
See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#ifndef GDCMBITMAP_H
#define GDCMBITMAP_H
#include "gdcmObject.h"
#include "gdcmCurve.h"
#include "gdcmDataElement.h"
//#include "gdcmIconImage.h"
#include "gdcmLookupTable.h"
#include "gdcmOverlay.h"
#include "gdcmPhotometricInterpretation.h"
#include "gdcmPixelFormat.h"
#include "gdcmSmartPointer.h"
#include "gdcmTransferSyntax.h"
#include <vector>
namespace gdcm
{
class GDCM_EXPORT Bitmap : public Object
{
public:
Bitmap();
~Bitmap() override;
void Print(std::ostream &) const override;
virtual bool AreOverlaysInPixelData() const { return false; }
virtual bool UnusedBitsPresentInPixelData() const { return false; }
unsigned int GetNumberOfDimensions() const;
void SetNumberOfDimensions(unsigned int dim);
unsigned int GetPlanarConfiguration() const;
void SetPlanarConfiguration(unsigned int pc);
bool GetNeedByteSwap() const
{
return NeedByteSwap;
}
void SetNeedByteSwap(bool b)
{
NeedByteSwap = b;
}
void SetTransferSyntax(TransferSyntax const &ts) {
TS = ts;
}
const TransferSyntax &GetTransferSyntax() const {
return TS;
}
bool IsTransferSyntaxCompatible( TransferSyntax const & ts ) const;
void SetDataElement(DataElement const &de) {
PixelData = de;
}
const DataElement& GetDataElement() const { return PixelData; }
DataElement& GetDataElement() { return PixelData; }
void SetLUT(LookupTable const &lut)
{
LUT = SmartPointer<LookupTable>( const_cast<LookupTable*>(&lut) );
}
const LookupTable &GetLUT() const
{
return *LUT;
}
LookupTable &GetLUT()
{
return *LUT;
}
const unsigned int *GetDimensions() const;
unsigned int GetDimension(unsigned int idx) const;
void SetColumns(unsigned int col) { SetDimension(0,col); }
unsigned int GetColumns() const { return GetDimension(0); }
void SetRows(unsigned int rows) { SetDimension(1,rows); }
unsigned int GetRows() const { return GetDimension(1); }
void SetDimensions(const unsigned int dims[3]);
void SetDimension(unsigned int idx, unsigned int dim);
const PixelFormat &GetPixelFormat() const
{
return PF;
}
PixelFormat &GetPixelFormat()
{
return PF;
}
void SetPixelFormat(PixelFormat const &pf)
{
PF = pf;
PF.Validate();
}
const PhotometricInterpretation &GetPhotometricInterpretation() const;
void SetPhotometricInterpretation(PhotometricInterpretation const &pi);
bool IsEmpty() const { return Dimensions.empty(); }
void Clear();
unsigned long GetBufferLength() const;
bool GetBuffer(char *buffer) const;
bool IsLossy() const;
void SetLossyFlag(bool f) { LossyFlag = f; }
protected:
bool TryRAWCodec(char *buffer, bool &lossyflag) const;
bool TryJPEGCodec(char *buffer, bool &lossyflag) const;
bool TryPVRGCodec(char *buffer, bool &lossyflag) const;
bool TryKAKADUCodec(char *buffer, bool &lossyflag) const;
bool TryJPEGLSCodec(char *buffer, bool &lossyflag) const;
bool TryJPEG2000Codec(char *buffer, bool &lossyflag) const;
bool TryRLECodec(char *buffer, bool &lossyflag) const;
bool TryJPEGCodec2(std::ostream &os) const;
bool TryJPEG2000Codec2(std::ostream &os) const;
bool GetBuffer2(std::ostream &os) const;
friend class PixmapReader;
friend class ImageChangeTransferSyntax;
// Function to compute the lossy flag based only on the image buffer.
// Watch out that image can be lossy but in implicit little endian format...
bool ComputeLossyFlag();
//private:
protected:
unsigned int PlanarConfiguration;
unsigned int NumberOfDimensions;
TransferSyntax TS;
PixelFormat PF; // SamplesPerPixel, BitsAllocated, BitsStored, HighBit, PixelRepresentation
PhotometricInterpretation PI;
// Mind dump: unsigned int is required here, since we are reading (0028,0008) Number Of Frames
// which is VR::IS, so I cannot simply assumed that unsigned short is enough... :(
std::vector<unsigned int> Dimensions; // Col/Row
DataElement PixelData; // copied from 7fe0,0010
typedef SmartPointer<LookupTable> LUTPtr;
LUTPtr LUT;
// I believe the following 3 ivars can be derived from TS ...
bool NeedByteSwap; // FIXME: remove me
bool LossyFlag;
private:
bool GetBufferInternal(char *buffer, bool &lossyflag) const;
};
} // end namespace gdcm
#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