Panda3D

pnmFileTypeSoftImage.h

00001 // Filename: pnmFileTypeSoftImage.h
00002 // Created by:  drose (17Jun00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef PNMFILETYPESOFTIMAGE_H
00016 #define PNMFILETYPESOFTIMAGE_H
00017 
00018 #include "pandabase.h"
00019 
00020 #ifdef HAVE_SOFTIMAGE_PIC
00021 
00022 #include "pnmFileType.h"
00023 #include "pnmReader.h"
00024 #include "pnmWriter.h"
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //       Class : PNMFileTypeSoftImage
00028 // Description : For reading and SoftImage native image files.
00029 ////////////////////////////////////////////////////////////////////
00030 class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeSoftImage : public PNMFileType {
00031 public:
00032   PNMFileTypeSoftImage();
00033 
00034   virtual string get_name() const;
00035 
00036   virtual int get_num_extensions() const;
00037   virtual string get_extension(int n) const;
00038   virtual string get_suggested_extension() const;
00039 
00040   virtual bool has_magic_number() const;
00041   virtual bool matches_magic_number(const string &magic_number) const;
00042 
00043   virtual PNMReader *make_reader(istream *file, bool owns_file = true,
00044                                  const string &magic_number = string());
00045   virtual PNMWriter *make_writer(ostream *file, bool owns_file = true);
00046 
00047 public:
00048   class Reader : public PNMReader {
00049   public:
00050     Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number);
00051 
00052     virtual bool supports_read_row() const;
00053     virtual bool read_row(xel *array, xelval *alpha, int x_size, int y_size);
00054 
00055   private:
00056     enum { unknown, rgb, rgba, rgb_a } soft_color;
00057     int rgb_ctype, alpha_ctype;
00058   };
00059 
00060   class Writer : public PNMWriter {
00061   public:
00062     Writer(PNMFileType *type, ostream *file, bool owns_file);
00063 
00064     virtual bool supports_write_row() const;
00065     virtual bool write_header();
00066     virtual bool write_row(xel *array, xelval *alpha);
00067   };
00068 
00069 
00070   // The TypedWritable interface follows.
00071 public:
00072   static void register_with_read_factory();
00073 
00074 protected:
00075   static TypedWritable *make_PNMFileTypeSoftImage(const FactoryParams &params);
00076 
00077 public:
00078   static TypeHandle get_class_type() {
00079     return _type_handle;
00080   }
00081   static void init_type() {
00082     PNMFileType::init_type();
00083     register_type(_type_handle, "PNMFileTypeSoftImage",
00084                   PNMFileType::get_class_type());
00085   }
00086   virtual TypeHandle get_type() const {
00087     return get_class_type();
00088   }
00089   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00090 
00091 private:
00092   static TypeHandle _type_handle;
00093 };
00094 
00095 #endif  // HAVE_SOFTIMAGE_PIC
00096 
00097 #endif
00098 
00099 
 All Classes Functions Variables Enumerations