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/11/17 21:57:25 $
00007   Version:   $Revision: 1.12 $
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 #include "itkImageIOBase.h"
00021 #include <fstream>
00022 
00023 namespace itk
00024 {
00025 
00026 //BTX
00027 class TIFFReaderInternal;
00028 //ETX
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   /*-------- This part of the interface deals with reading data. ------ */
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   /*-------- This part of the interfaces deals with writing data. ----- */
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   //BTX
00087   enum { // Compression types
00088     NoCompression,
00089     PackBits,
00090     JPEG,
00091     Deflate,
00092     LZW
00093   };
00094   //ETX
00095 
00096   // Description:
00097   // Set compression type. Sinze LZW compression is patented outside US, the
00098   // additional work steps have to be taken in order to use that compression.
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     // This If block isn't strictly necessary:
00110     // SetCompression(true); would be sufficient.  However, it reads strangely
00111     // for SetCompression(NoCompression) to then set SetCompression(true).
00112     // Doing it this way is probaly also less likely to break in the future.
00113     if (compression == NoCompression)
00114       {
00115       this->SetUseCompression(false); // this is for the ImageIOBase class
00116       }
00117     else
00118       {
00119       this->SetUseCompression(true);  // this is for the ImageIOBase class
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   // To support Zeiss images
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   // Check that tag t can be found
00149   bool  CanFindTIFFTag(unsigned int t);
00150   // Read and returns the raw bytes of tag t
00151   void *ReadRawByteFromTag( unsigned int t, short &value_count );
00152 
00153   TIFFReaderInternal * m_InternalImage;
00154   int m_Compression;
00155 private:
00156   TIFFImageIO(const Self&); //purposely not implemented
00157   void operator=(const Self&); //purposely not implemented
00158 
00159   unsigned short *ColorRed;
00160   unsigned short *ColorGreen;
00161   unsigned short *ColorBlue;
00162   int TotalColors;
00163   unsigned int ImageFormat;
00164 };
00165 
00166 } // end namespace itk
00167 
00168 #endif // __itkTIFFImageIO_h
00169 
00170 

Generated at Mon Mar 12 03:12:51 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000