GDCM 2.2.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

gdcmBitmap.h
Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program: GDCM (Grassroots DICOM). A DICOM library
    00004
    00005   Copyright (c) 2006-2011 Mathieu Malaterre
    00006   All rights reserved.
    00007   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
    00008
    00009      This software is distributed WITHOUT ANY WARRANTY; without even
    00010      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00011      PURPOSE.  See the above copyright notice for more information.
    00012
    00013 =========================================================================*/
    00014 #ifndef GDCMBITMAP_H
    00015 #define GDCMBITMAP_H
    00016
    00017 #include "gdcmObject.h"
    00018 #include "gdcmCurve.h"
    00019 #include "gdcmDataElement.h"
    00020 //#include "gdcmIconImage.h"
    00021 #include "gdcmLookupTable.h"
    00022 #include "gdcmOverlay.h"
    00023 #include "gdcmPhotometricInterpretation.h"
    00024 #include "gdcmPixelFormat.h"
    00025 #include "gdcmSmartPointer.h"
    00026 #include "gdcmTransferSyntax.h"
    00027
    00028 #include <vector>
    00029
    00030 namespace gdcm
    00031 {
    00032
    00038 class GDCM_EXPORT Bitmap : public Object
    00039 {
    00040 public:
    00041   Bitmap();
    00042   ~Bitmap();
    00043   void Print(std::ostream &) const;
    00044
    00045   virtual bool AreOverlaysInPixelData() const { return false; }
    00046
    00048   unsigned int GetNumberOfDimensions() const;
    00049   void SetNumberOfDimensions(unsigned int dim);
    00050
    00052   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   bool IsTransferSyntaxCompatible( TransferSyntax const & ts ) const;
    00074   void SetDataElement(DataElement const &de) {
    00075     PixelData = de;
    00076   }
    00077   const DataElement& GetDataElement() const { return PixelData; }
    00078   DataElement& GetDataElement() { return PixelData; }
    00079
    00081   void SetLUT(LookupTable const &lut)
    00082     {
    00083     LUT = SmartPointer<LookupTable>( const_cast<LookupTable*>(&lut) );
    00084     }
    00085   const LookupTable &GetLUT() const
    00086     {
    00087     return *LUT;
    00088     }
    00089   LookupTable &GetLUT()
    00090     {
    00091     return *LUT;
    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 TryKAKADUCodec(char *buffer, bool &lossyflag) const;
    00145   bool TryJPEGLSCodec(char *buffer, bool &lossyflag) const;
    00146   bool TryJPEG2000Codec(char *buffer, bool &lossyflag) const;
    00147   bool TryRLECodec(char *buffer, bool &lossyflag) const;
    00148
    00149   bool TryJPEGCodec2(std::ostream &os) const;
    00150   bool TryJPEG2000Codec2(std::ostream &os) const;
    00151
    00152   bool GetBuffer2(std::ostream &os) const;
    00153
    00154   friend class PixmapReader;
    00155   friend class ImageChangeTransferSyntax;
    00156   // Function to compute the lossy flag based only on the image buffer.
    00157   // Watch out that image can be lossy but in implicit little endian format...
    00158   bool ComputeLossyFlag();
    00159
    00160 //private:
    00161 protected:
    00162   unsigned int PlanarConfiguration;
    00163   unsigned int NumberOfDimensions;
    00164   TransferSyntax TS;
    00165   PixelFormat PF; // SamplesPerPixel, BitsAllocated, BitsStored, HighBit, PixelRepresentation
    00166   PhotometricInterpretation PI;
    00167   // Mind dump: unsigned int is required here, since we are reading (0028,0008) Number Of Frames
    00168   // which is VR::IS, so I cannot simply assumed that unsigned short is enough... :(
    00169   std::vector<unsigned int> Dimensions; // Col/Row
    00170   DataElement PixelData; // copied from 7fe0,0010
    00171
    00172   typedef SmartPointer<LookupTable> LUTPtr;
    00173   LUTPtr LUT;
    00174   // I believe the following 3 ivars can be derived from TS ...
    00175   bool NeedByteSwap;
    00176   bool LossyFlag;
    00177
    00178 private:
    00179   bool GetBufferInternal(char *buffer, bool &lossyflag) const;
    00180 };
    00181
    00182 } // end namespace gdcm
    00183
    00184 #endif //GDCMBITMAP_H