GDCM
2.0.18
|
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 Decode(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) 00097 { 00098 Dimensions[0] = d[0]; 00099 Dimensions[1] = d[1]; 00100 Dimensions[2] = d[2]; 00101 } 00102 00103 void SetDimensions(const std::vector<unsigned int> & d) 00104 { 00105 size_t theSize = d.size(); 00106 assert(theSize<= 3); 00107 for (size_t i = 0; i < 3; i++) 00108 { 00109 if (i < theSize) 00110 Dimensions[i] = d[i]; 00111 else 00112 Dimensions[i] = 1; 00113 } 00114 } 00115 const unsigned int *GetDimensions() const { return Dimensions; } 00116 void SetNumberOfDimensions(unsigned int dim); 00117 unsigned int GetNumberOfDimensions() const; 00118 00119 protected: 00120 bool RequestPlanarConfiguration; 00121 bool RequestPaddedCompositePixelCode; 00122 //private: 00123 unsigned int PlanarConfiguration; 00124 PhotometricInterpretation PI; 00125 PixelFormat PF; 00126 bool NeedByteSwap; 00127 bool NeedOverlayCleanup; 00128 00129 typedef SmartPointer<LookupTable> LUTPtr; 00130 LUTPtr LUT; 00131 unsigned int Dimensions[3]; // FIXME 00132 unsigned int NumberOfDimensions; 00133 bool LossyFlag; 00134 00135 bool DoOverlayCleanup(std::istream &is_, std::ostream &os); 00136 bool DoByteSwap(std::istream &is_, std::ostream &os); 00137 bool DoYBR(std::istream &is_, std::ostream &os); 00138 bool DoPlanarConfiguration(std::istream &is_, std::ostream &os); 00139 bool DoSimpleCopy(std::istream &is_, std::ostream &os); 00140 bool DoPaddedCompositePixelCode(std::istream &is_, std::ostream &os); 00141 bool DoInvertMonochrome(std::istream &is_, std::ostream &os); 00142 00143 //template <typename T> 00144 //bool DoInvertPlanarConfiguration(T *output, const T *input, uint32_t length); 00145 }; 00146 00147 } // end namespace gdcm 00148 00149 #endif //GDCMIMAGECODEC_H