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