# 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-2009 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 CanDecode(TransferSyntax const &) const { return false; }
    00038   bool Decode(DataElement const &is, DataElement &os);
    00039   bool IsLossy() const;
    00040
    00041   virtual bool GetHeaderInfo(std::istream &is, TransferSyntax &ts);
    00042
    00043 protected:
    00044   bool Decode(std::istream &is, std::ostream &os);
    00045   virtual bool IsValid(PhotometricInterpretation const &pi);
    00046 public:
    00047
    00048   unsigned int GetPlanarConfiguration() const
    00049     {
    00050     return PlanarConfiguration;
    00051     }
    00052   void SetPlanarConfiguration(unsigned int pc)
    00053     {
    00054     assert( pc == 0 || pc == 1 );
    00055     PlanarConfiguration = pc;
    00056     }
    00057
    00058   PixelFormat &GetPixelFormat()
    00059     {
    00060     return PF;
    00061     }
    00062   const PixelFormat &GetPixelFormat() const
    00063     {
    00064     return PF;
    00065     }
    00066   virtual void SetPixelFormat(PixelFormat const &pf)
    00067     {
    00068     PF = pf;
    00069     }
    00070   const PhotometricInterpretation &GetPhotometricInterpretation() const;
    00071   void SetPhotometricInterpretation(PhotometricInterpretation const &pi);
    00072
    00073   bool GetNeedByteSwap() const
    00074     {
    00075     return NeedByteSwap;
    00076     }
    00077   void SetNeedByteSwap(bool b)
    00078     {
    00079     NeedByteSwap = b;
    00080     }
    00081   void SetNeedOverlayCleanup(bool b)
    00082     {
    00083     NeedOverlayCleanup = b;
    00084     }
    00085   void SetLUT(LookupTable const &lut)
    00086     {
    00087     LUT = SmartPointer<LookupTable>( const_cast<LookupTable*>(&lut) );
    00088     }
    00089   const LookupTable &GetLUT() const
    00090     {
    00091     return *LUT;
    00092     }
    00093
    00094   void SetDimensions(const unsigned int *d)
    00095     {
    00096     Dimensions[0] = d[0];
    00097     Dimensions[1] = d[1];
    00098     Dimensions[2] = d[2];
    00099     }
    00100   const unsigned int *GetDimensions() const { return Dimensions; }
    00101   void SetNumberOfDimensions(unsigned int dim);
    00102 protected:
    00103   bool RequestPlanarConfiguration;
    00104   bool RequestPaddedCompositePixelCode;
    00105 //private:
    00106   unsigned int PlanarConfiguration;
    00107   PhotometricInterpretation PI;
    00108   PixelFormat PF;
    00109   bool NeedByteSwap;
    00110   bool NeedOverlayCleanup;
    00111
    00112   typedef SmartPointer<LookupTable> LUTPtr;
    00113   LUTPtr LUT;
    00114   unsigned int Dimensions[3]; // FIXME
    00115   unsigned int NumberOfDimensions;
    00116   bool LossyFlag;
    00117
    00118   bool DoOverlayCleanup(std::istream &is, std::ostream &os);
    00119   bool DoByteSwap(std::istream &is, std::ostream &os);
    00120   bool DoYBR(std::istream &is, std::ostream &os);
    00121   bool DoPlanarConfiguration(std::istream &is, std::ostream &os);
    00122   bool DoSimpleCopy(std::istream &is, std::ostream &os);
    00123   bool DoPaddedCompositePixelCode(std::istream &is, std::ostream &os);
    00124   bool DoInvertMonochrome(std::istream &is, std::ostream &os);
    00125
    00126   //template <typename T>
    00127   //bool DoInvertPlanarConfiguration(T *output, const T *input, uint32_t length);
    00128 };
    00129
    00130 } // end namespace gdcm
    00131
    00132 #endif //__gdcmImageCodec_h