gdcmBitmap.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef __gdcmBitmap_h
00016 #define __gdcmBitmap_h
00017
00018 #include "gdcmObject.h"
00019 #include "gdcmCurve.h"
00020 #include "gdcmDataElement.h"
00021
00022 #include "gdcmLookupTable.h"
00023 #include "gdcmOverlay.h"
00024 #include "gdcmPhotometricInterpretation.h"
00025 #include "gdcmPixelFormat.h"
00026 #include "gdcmSmartPointer.h"
00027 #include "gdcmTransferSyntax.h"
00028
00029 #include <vector>
00030
00031 namespace gdcm
00032 {
00033
00039 class GDCM_EXPORT Bitmap : public Object
00040 {
00041 public:
00042 Bitmap();
00043 ~Bitmap();
00044 void Print(std::ostream &) const {}
00045
00046 virtual bool AreOverlaysInPixelData() const { return false; }
00047
00049 unsigned int GetNumberOfDimensions() const;
00050 void SetNumberOfDimensions(unsigned int dim);
00051
00053 unsigned int GetPlanarConfiguration() const;
00054 void SetPlanarConfiguration(unsigned int pc);
00055
00056 bool GetNeedByteSwap() const
00057 {
00058 return NeedByteSwap;
00059 }
00060 void SetNeedByteSwap(bool b)
00061 {
00062 NeedByteSwap = b;
00063 }
00064
00065
00067 void SetTransferSyntax(TransferSyntax const &ts) {
00068 TS = ts;
00069 }
00070 const TransferSyntax &GetTransferSyntax() const {
00071 return TS;
00072 }
00073 void SetDataElement(DataElement const &de) {
00074 PixelData = de;
00075 }
00076 const DataElement& GetDataElement() const { return PixelData; }
00077 DataElement& GetDataElement() { return PixelData; }
00078
00080 void SetLUT(LookupTable const &lut)
00081 {
00082 LUT = SmartPointer<LookupTable>( const_cast<LookupTable*>(&lut) );
00083 }
00084 const LookupTable &GetLUT() const
00085 {
00086 return *LUT;
00087 }
00088 LookupTable &GetLUT()
00089 {
00090 return *LUT;
00091 }
00092
00093
00095 const unsigned int *GetDimensions() const;
00096 unsigned int GetDimension(unsigned int idx) const;
00097
00098 void SetColumns(unsigned int col) { SetDimension(0,col); }
00099 unsigned int GetColumns() const { return GetDimension(0); }
00100 void SetRows(unsigned int rows) { SetDimension(1,rows); }
00101 unsigned int GetRows() const { return GetDimension(1); }
00102 void SetDimensions(const unsigned int dims[3]);
00103 void SetDimension(unsigned int idx, unsigned int dim);
00105 const PixelFormat &GetPixelFormat() const
00106 {
00107 return PF;
00108 }
00109 PixelFormat &GetPixelFormat()
00110 {
00111 return PF;
00112 }
00113 void SetPixelFormat(PixelFormat const &pf)
00114 {
00115 PF = pf;
00116 PF.Validate();
00117 }
00118
00120 const PhotometricInterpretation &GetPhotometricInterpretation() const;
00121 void SetPhotometricInterpretation(PhotometricInterpretation const &pi);
00122
00123 bool IsEmpty() const { return Dimensions.size() == 0; }
00124 void Clear();
00125
00129 unsigned long GetBufferLength() const;
00130
00132 bool GetBuffer(char *buffer) const;
00133
00135 bool IsLossy() const;
00136
00138 void SetLossyFlag(bool f) { LossyFlag = f; }
00139
00140 protected:
00141 bool TryRAWCodec(char *buffer, bool &lossyflag) const;
00142 bool TryJPEGCodec(char *buffer, bool &lossyflag) const;
00143 bool TryPVRGCodec(char *buffer, bool &lossyflag) const;
00144 bool TryJPEGLSCodec(char *buffer, bool &lossyflag) const;
00145 bool TryJPEG2000Codec(char *buffer, bool &lossyflag) const;
00146 bool TryRLECodec(char *buffer, bool &lossyflag) const;
00147
00148 bool TryJPEGCodec2(std::ostream &os) const;
00149 bool TryJPEG2000Codec2(std::ostream &os) const;
00150
00151 bool GetBuffer2(std::ostream &os) const;
00152
00153 friend class PixmapReader;
00154 friend class ImageChangeTransferSyntax;
00155 bool ComputeLossyFlag();
00156
00157
00158 protected:
00159 unsigned int PlanarConfiguration;
00160 unsigned int NumberOfDimensions;
00161 TransferSyntax TS;
00162 PixelFormat PF;
00163 PhotometricInterpretation PI;
00164
00165
00166 std::vector<unsigned int> Dimensions;
00167 DataElement PixelData;
00168
00169 typedef SmartPointer<LookupTable> LUTPtr;
00170 LUTPtr LUT;
00171
00172 bool NeedByteSwap;
00173 bool LossyFlag;
00174
00175 private:
00176 bool GetBufferInternal(char *buffer, bool &lossyflag) const;
00177 };
00178
00179 }
00180
00181 #endif //__gdcmBitmap_h