00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkTIFFImageIO_h
00018 #define __itkTIFFImageIO_h
00019
00020 #ifdef _MSC_VER
00021 #pragma warning ( disable : 4786 )
00022 #endif
00023
00024 #include <fstream>
00025 #include "itkImageIOBase.h"
00026
00027 namespace itk
00028 {
00029
00030
00031
00032
00033
00034
00035
00036
00037 class TIFFReaderInternal;
00038
00039
00040 class ITK_EXPORT TIFFImageIO : public ImageIOBase
00041 {
00042 public:
00044 typedef TIFFImageIO Self;
00045 typedef ImageIOBase Superclass;
00046 typedef SmartPointer<Self> Pointer;
00047
00049 itkNewMacro(Self);
00050
00052 itkTypeMacro(TIFFImageIO, ImageIOBase);
00053
00054
00055
00058 virtual bool CanReadFile(const char*);
00059
00061 virtual void ReadImageInformation();
00062
00064 virtual void Read(void* buffer);
00065
00067 virtual void ReadVolume(void* buffer);
00068
00070 virtual void ReadTiles(void* buffer);
00071
00072
00073
00076 virtual bool CanWriteFile(const char*);
00077
00080 virtual void WriteImageInformation();
00081
00084 virtual void Write(const void* buffer);
00085
00086 enum { NOFORMAT, RGB_, GRAYSCALE, PALETTE_RGB, PALETTE_GRAYSCALE, OTHER };
00087
00088
00089 enum {
00090 NoCompression,
00091 PackBits,
00092 JPEG,
00093 Deflate,
00094 LZW
00095 };
00096
00097
00098
00099
00100
00101 void SetCompressionToNoCompression() { this->SetCompression(NoCompression); }
00102 void SetCompressionToPackBits() { this->SetCompression(PackBits); }
00103 void SetCompressionToJPEG() { this->SetCompression(JPEG); }
00104 void SetCompressionToDeflate() { this->SetCompression(Deflate); }
00105 void SetCompressionToLZW() { this->SetCompression(LZW); }
00106
00107 void SetCompression(int compression)
00108 {
00109 m_Compression = compression;
00110
00111
00112
00113
00114
00115 if (compression == NoCompression)
00116 {
00117 this->SetUseCompression(false);
00118 }
00119 else
00120 {
00121 this->SetUseCompression(true);
00122 }
00123 }
00124
00125
00126 protected:
00127 TIFFImageIO();
00128 ~TIFFImageIO();
00129 void PrintSelf(std::ostream& os, Indent indent) const;
00130
00131 void WriteSlice(std::string& fileName, const void* buffer);
00132 void WriteVolume(std::string& fileName, const void* buffer);
00133
00134 void InitializeColors();
00135 void ReadGenericImage( void *out,
00136 unsigned int itkNotUsed(width),
00137 unsigned int height );
00138 int EvaluateImageAt( void* out, void* in );
00139
00140 unsigned int GetFormat();
00141
00142 void GetColor( int index, unsigned short *red,
00143 unsigned short *green, unsigned short *blue );
00144
00145
00146 private:
00147 TIFFImageIO(const Self&);
00148 void operator=(const Self&);
00149
00150 unsigned short *ColorRed;
00151 unsigned short *ColorGreen;
00152 unsigned short *ColorBlue;
00153 int TotalColors;
00154 unsigned int ImageFormat;
00155 TIFFReaderInternal * m_InternalImage;
00156 int m_Compression;
00157 };
00158
00159 }
00160
00161 #endif // __itkTIFFImageIO_h
00162