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 #include "itkImageIOBase.h"
00021 #include <fstream>
00022
00023 namespace itk
00024 {
00025
00026
00027 class TIFFReaderInternal;
00028
00029
00030
00038 class ITK_EXPORT TIFFImageIO : public ImageIOBase
00039 {
00040 public:
00042 typedef TIFFImageIO Self;
00043 typedef ImageIOBase Superclass;
00044 typedef SmartPointer<Self> Pointer;
00045
00047 itkNewMacro(Self);
00048
00050 itkTypeMacro(TIFFImageIO, ImageIOBase);
00051
00052
00053
00056 virtual bool CanReadFile(const char*);
00057
00059 virtual void ReadImageInformation();
00060
00062 virtual void Read(void* buffer);
00063
00065 virtual void ReadVolume(void* buffer);
00066
00068 virtual void ReadTiles(void* buffer);
00069
00070
00071
00074 virtual bool CanWriteFile(const char*);
00075
00078 virtual void WriteImageInformation();
00079
00082 virtual void Write(const void* buffer);
00083
00084 enum { NOFORMAT, RGB_, GRAYSCALE, PALETTE_RGB, PALETTE_GRAYSCALE, OTHER };
00085
00086
00087 enum {
00088 NoCompression,
00089 PackBits,
00090 JPEG,
00091 Deflate,
00092 LZW
00093 };
00094
00095
00096
00097
00098
00099 void SetCompressionToNoCompression() { this->SetCompression(NoCompression); }
00100 void SetCompressionToPackBits() { this->SetCompression(PackBits); }
00101 void SetCompressionToJPEG() { this->SetCompression(JPEG); }
00102 void SetCompressionToDeflate() { this->SetCompression(Deflate); }
00103 void SetCompressionToLZW() { this->SetCompression(LZW); }
00104
00105 void SetCompression(int compression)
00106 {
00107 m_Compression = compression;
00108
00109
00110
00111
00112
00113 if (compression == NoCompression)
00114 {
00115 this->SetUseCompression(false);
00116 }
00117 else
00118 {
00119 this->SetUseCompression(true);
00120 }
00121 }
00122
00123
00124 protected:
00125 TIFFImageIO();
00126 ~TIFFImageIO();
00127 void PrintSelf(std::ostream& os, Indent indent) const;
00128
00129 void InternalWrite(const void* buffer);
00130
00131 void InitializeColors();
00132 void ReadGenericImage( void *out,
00133 unsigned int itkNotUsed(width),
00134 unsigned int height );
00135
00136
00137 void ReadTwoSamplesPerPixelImage( void *out,
00138 unsigned int itkNotUsed(width),
00139 unsigned int height );
00140
00141
00142 int EvaluateImageAt( void* out, void* in );
00143
00144 unsigned int GetFormat();
00145
00146 void GetColor( int index, unsigned short *red,
00147 unsigned short *green, unsigned short *blue );
00148
00149 bool CanFindTIFFTag(unsigned int t);
00150
00151 void *ReadRawByteFromTag( unsigned int t, short &value_count );
00152
00153 TIFFReaderInternal * m_InternalImage;
00154 int m_Compression;
00155 private:
00156 TIFFImageIO(const Self&);
00157 void operator=(const Self&);
00158
00159 unsigned short *ColorRed;
00160 unsigned short *ColorGreen;
00161 unsigned short *ColorBlue;
00162 int TotalColors;
00163 unsigned int ImageFormat;
00164 };
00165
00166 }
00167
00168 #endif // __itkTIFFImageIO_h
00169