Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/pnmimagetypes/pnmFileTypeTIFF.h

Go to the documentation of this file.
00001 // Filename: pnmFileTypeTIFF.h
00002 // Created by:  drose (17Jun00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef PNMFILETYPETIFF_H
00020 #define PNMFILETYPETIFF_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "pnmFileType.h"
00025 #include "pnmReader.h"
00026 #include "pnmWriter.h"
00027 
00028 #include <stdarg.h>  // for va_list
00029 
00030 
00031 #define TIFF_COLORMAP_MAXCOLORS 1024
00032 
00033 ////////////////////////////////////////////////////////////////////
00034 //       Class : PNMFileTypeTIFF
00035 // Description : For reading and writing TIFF files.
00036 ////////////////////////////////////////////////////////////////////
00037 class EXPCL_PANDA PNMFileTypeTIFF : public PNMFileType {
00038 public:
00039   PNMFileTypeTIFF();
00040 
00041   virtual string get_name() const;
00042 
00043   virtual int get_num_extensions() const;
00044   virtual string get_extension(int n) const;
00045   virtual string get_suggested_extension() const;
00046 
00047   virtual bool has_magic_number() const;
00048   virtual bool matches_magic_number(const string &magic_number) const;
00049 
00050   virtual PNMReader *make_reader(istream *file, bool owns_file = true,
00051                                  const string &magic_number = string());
00052   virtual PNMWriter *make_writer(ostream *file, bool owns_file = true);
00053 
00054 public:
00055   class Reader : public PNMReader {
00056   public:
00057     Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number);
00058     virtual ~Reader();
00059 
00060     virtual bool supports_read_row() const;
00061     virtual bool read_row(xel *array, xelval *alpha);
00062 
00063   private:
00064     unsigned short photomet;
00065     unsigned short bps, spp;
00066     xel colormap[TIFF_COLORMAP_MAXCOLORS];
00067 
00068     int current_row;
00069     struct tiff *tif;
00070   };
00071 
00072   class Writer : public PNMWriter {
00073   public:
00074     Writer(PNMFileType *type, ostream *file, bool owns_file);
00075 
00076     virtual int write_data(xel *array, xelval *alpha);
00077   };
00078 
00079 private:
00080   static void install_error_handlers();
00081 
00082   static void tiff_warning(const char *module, const char *format, va_list ap);
00083   static void tiff_error(const char *module, const char *format, va_list ap);
00084   static bool _installed_error_handlers;
00085 
00086   // The TypedWritable interface follows.
00087 public:
00088   static void register_with_read_factory();
00089 
00090 protected:
00091   static TypedWritable *make_PNMFileTypeTIFF(const FactoryParams &params);
00092 
00093 public:
00094   static TypeHandle get_class_type() {
00095     return _type_handle;
00096   }
00097   static void init_type() {
00098     PNMFileType::init_type();
00099     register_type(_type_handle, "PNMFileTypeTIFF",
00100                   PNMFileType::get_class_type());
00101   }
00102   virtual TypeHandle get_type() const {
00103     return get_class_type();
00104   }
00105   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00106 
00107 private:
00108   static TypeHandle _type_handle;
00109 };
00110 
00111 #endif
00112 
00113 

Generated on Fri May 2 00:43:26 2003 for Panda by doxygen1.3