Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkTIFFImageIO.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkTIFFImageIO.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/01/16 23:13:28 $
00007   Version:   $Revision: 1.8 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
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 /* \brief ImageIO object for reading and writing TIFF images
00031  *
00032  * \ingroup IOFilters
00033  *
00034  */
00035 
00036 //BTX
00037 class TIFFReaderInternal;
00038 //ETX
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   /*-------- This part of the interface deals with reading data. ------ */
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   /*-------- This part of the interfaces deals with writing data. ----- */
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   //BTX
00089   enum { // Compression types
00090     NoCompression,
00091     PackBits,
00092     JPEG,
00093     Deflate,
00094     LZW
00095   };
00096   //ETX
00097 
00098   // Description:
00099   // Set compression type. Sinze LZW compression is patented outside US, the
00100   // additional work steps have to be taken in order to use that compression.
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     // This If block isn't strictly necessary:
00112     // SetCompression(true); would be sufficient.  However, it reads strangely
00113     // for SetCompression(NoCompression) to then set SetCompression(true).
00114     // Doing it this way is probaly also less likely to break in the future.
00115     if (compression == NoCompression)
00116       {
00117       this->SetUseCompression(false); // this is for the ImageIOBase class
00118       }
00119     else
00120       {
00121       this->SetUseCompression(true);  // this is for the ImageIOBase class
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&); //purposely not implemented
00148   void operator=(const Self&); //purposely not implemented
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 } // end namespace itk
00160 
00161 #endif // __itkTIFFImageIO_h
00162 

Generated at Wed Mar 30 00:13:00 2005 for ITK by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2000