GDCM
2.2.3
|
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 GDCMIMAGECODEC_H 00015 #define GDCMIMAGECODEC_H 00016 00017 #include "gdcmCodec.h" 00018 #include "gdcmPhotometricInterpretation.h" 00019 #include "gdcmLookupTable.h" 00020 #include "gdcmSmartPointer.h" 00021 #include "gdcmPixelFormat.h" 00022 00023 namespace gdcm 00024 { 00025 00030 class GDCM_EXPORT ImageCodec : public Codec 00031 { 00032 friend class ImageChangePhotometricInterpretation; 00033 public: 00034 ImageCodec(); 00035 ~ImageCodec(); 00036 bool CanCode(TransferSyntax const &) const { return false; } 00037 bool CanDecode(TransferSyntax const &) const { return false; } 00038 bool Decode(DataElement const &is_, DataElement &os); 00039 bool IsLossy() const; 00040 void SetLossyFlag(bool l); 00041 bool GetLossyFlag() const; 00042 00043 virtual bool GetHeaderInfo(std::istream &is_, TransferSyntax &ts); 00044 00045 protected: 00046 bool DecodeByStreams(std::istream &is_, std::ostream &os); 00047 virtual bool IsValid(PhotometricInterpretation const &pi); 00048 public: 00049 00050 unsigned int GetPlanarConfiguration() const 00051 { 00052 return PlanarConfiguration; 00053 } 00054 void SetPlanarConfiguration(unsigned int pc) 00055 { 00056 assert( pc == 0 || pc == 1 ); 00057 PlanarConfiguration = pc; 00058 } 00059 00060 PixelFormat &GetPixelFormat() 00061 { 00062 return PF; 00063 } 00064 const PixelFormat &GetPixelFormat() const 00065 { 00066 return PF; 00067 } 00068 virtual void SetPixelFormat(PixelFormat const &pf) 00069 { 00070 PF = pf; 00071 } 00072 const PhotometricInterpretation &GetPhotometricInterpretation() const; 00073 void SetPhotometricInterpretation(PhotometricInterpretation const &pi); 00074 00075 bool GetNeedByteSwap() const 00076 { 00077 return NeedByteSwap; 00078 } 00079 void SetNeedByteSwap(bool b) 00080 { 00081 NeedByteSwap = b; 00082 } 00083 void SetNeedOverlayCleanup(bool b) 00084 { 00085 NeedOverlayCleanup = b; 00086 } 00087 void SetLUT(LookupTable const &lut) 00088 { 00089 LUT = SmartPointer<LookupTable>( const_cast<LookupTable*>(&lut) ); 00090 } 00091 const LookupTable &GetLUT() const 00092 { 00093 return *LUT; 00094 } 00095 00096 void SetDimensions(const unsigned int d[3]); 00097 void SetDimensions(const std::vector<unsigned int> & d); 00098 const unsigned int *GetDimensions() const { return Dimensions; } 00099 void SetNumberOfDimensions(unsigned int dim); 00100 unsigned int GetNumberOfDimensions() const; 00101 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