# gdcmImageCodec.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program: GDCM (Grassroots DICOM). A DICOM library
    00004   Module:  $URL$
    00005
    00006   Copyright (c) 2006-2010 Mathieu Malaterre
    00007   All rights reserved.
    00008   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
    00009
    00010      This software is distributed WITHOUT ANY WARRANTY; without even
    00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00012      PURPOSE.  See the above copyright notice for more information.
    00013
    00014 =========================================================================*/
    00015 #ifndef GDCMIMAGECODEC_H
    00016 #define GDCMIMAGECODEC_H
    00017
    00018 #include "gdcmCodec.h"
    00019 #include "gdcmPhotometricInterpretation.h"
    00020 #include "gdcmLookupTable.h"
    00021 #include "gdcmSmartPointer.h"
    00022 #include "gdcmPixelFormat.h"
    00023
    00024 namespace gdcm
    00025 {
    00026
    00031 class GDCM_EXPORT ImageCodec : public Codec
    00032 {
    00033   friend class ImageChangePhotometricInterpretation;
    00034 public:
    00035   ImageCodec();
    00036   ~ImageCodec();
    00037   bool CanCode(TransferSyntax const &) const { return false; }
    00038   bool CanDecode(TransferSyntax const &) const { return false; }
    00039   bool Decode(DataElement const &is_, DataElement &os);
    00040   bool IsLossy() const;
    00041   void SetLossyFlag(bool l);
    00042   bool GetLossyFlag() const;
    00043
    00044   virtual bool GetHeaderInfo(std::istream &is_, TransferSyntax &ts);
    00045
    00046 protected:
    00047   bool Decode(std::istream &is_, std::ostream &os);
    00048   virtual bool IsValid(PhotometricInterpretation const &pi);
    00049 public:
    00050
    00051   unsigned int GetPlanarConfiguration() const
    00052     {
    00053     return PlanarConfiguration;
    00054     }
    00055   void SetPlanarConfiguration(unsigned int pc)
    00056     {
    00057     assert( pc == 0 || pc == 1 );
    00058     PlanarConfiguration = pc;
    00059     }
    00060
    00061   PixelFormat &GetPixelFormat()
    00062     {
    00063     return PF;
    00064     }
    00065   const PixelFormat &GetPixelFormat() const
    00066     {
    00067     return PF;
    00068     }
    00069   virtual void SetPixelFormat(PixelFormat const &pf)
    00070     {
    00071     PF = pf;
    00072     }
    00073   const PhotometricInterpretation &GetPhotometricInterpretation() const;
    00074   void SetPhotometricInterpretation(PhotometricInterpretation const &pi);
    00075
    00076   bool GetNeedByteSwap() const
    00077     {
    00078     return NeedByteSwap;
    00079     }
    00080   void SetNeedByteSwap(bool b)
    00081     {
    00082     NeedByteSwap = b;
    00083     }
    00084   void SetNeedOverlayCleanup(bool b)
    00085     {
    00086     NeedOverlayCleanup = b;
    00087     }
    00088   void SetLUT(LookupTable const &lut)
    00089     {
    00090     LUT = SmartPointer<LookupTable>( const_cast<LookupTable*>(&lut) );
    00091     }
    00092   const LookupTable &GetLUT() const
    00093     {
    00094     return *LUT;
    00095     }
    00096
    00097   void SetDimensions(const unsigned int *d)
    00098     {
    00099     Dimensions[0] = d[0];
    00100     Dimensions[1] = d[1];
    00101     Dimensions[2] = d[2];
    00102     }
    00103   const unsigned int *GetDimensions() const { return Dimensions; }
    00104   void SetNumberOfDimensions(unsigned int dim);
    00105   unsigned int GetNumberOfDimensions() const;
    00106
    00107 protected:
    00108   bool RequestPlanarConfiguration;
    00109   bool RequestPaddedCompositePixelCode;
    00110 //private:
    00111   unsigned int PlanarConfiguration;
    00112   PhotometricInterpretation PI;
    00113   PixelFormat PF;
    00114   bool NeedByteSwap;
    00115   bool NeedOverlayCleanup;
    00116
    00117   typedef SmartPointer<LookupTable> LUTPtr;
    00118   LUTPtr LUT;
    00119   unsigned int Dimensions[3]; // FIXME
    00120   unsigned int NumberOfDimensions;
    00121   bool LossyFlag;
    00122
    00123   bool DoOverlayCleanup(std::istream &is_, std::ostream &os);
    00124   bool DoByteSwap(std::istream &is_, std::ostream &os);
    00125   bool DoYBR(std::istream &is_, std::ostream &os);
    00126   bool DoPlanarConfiguration(std::istream &is_, std::ostream &os);
    00127   bool DoSimpleCopy(std::istream &is_, std::ostream &os);
    00128   bool DoPaddedCompositePixelCode(std::istream &is_, std::ostream &os);
    00129   bool DoInvertMonochrome(std::istream &is_, std::ostream &os);
    00130
    00131   //template <typename T>
    00132   //bool DoInvertPlanarConfiguration(T *output, const T *input, uint32_t length);
    00133 };
    00134
    00135 } // end namespace gdcm
    00136
    00137 #endif //GDCMIMAGECODEC_H