00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef PNMFILETYPEPNM_H
00016 #define PNMFILETYPEPNM_H
00017
00018 #include "pandabase.h"
00019
00020 #ifdef HAVE_PNM
00021
00022 #include "pnmFileType.h"
00023 #include "pnmReader.h"
00024 #include "pnmWriter.h"
00025
00026
00027
00028
00029
00030
00031 class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypePNM : public PNMFileType {
00032 public:
00033 PNMFileTypePNM();
00034
00035 virtual string get_name() const;
00036
00037 virtual int get_num_extensions() const;
00038 virtual string get_extension(int n) const;
00039 virtual string get_suggested_extension() const;
00040
00041 virtual bool has_magic_number() const;
00042 virtual bool matches_magic_number(const string &magic_number) const;
00043
00044 virtual PNMReader *make_reader(istream *file, bool owns_file = true,
00045 const string &magic_number = string());
00046 virtual PNMWriter *make_writer(ostream *file, bool owns_file = true);
00047
00048 public:
00049 class Reader : public PNMReader {
00050 public:
00051 Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number);
00052
00053 virtual bool supports_read_row() const;
00054 virtual bool read_row(xel *array, xelval *alpha, int x_size, int y_size);
00055
00056 private:
00057 int _ftype;
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 private:
00069 int _pnm_format;
00070 };
00071
00072
00073
00074 public:
00075 static void register_with_read_factory();
00076
00077 protected:
00078 static TypedWritable *make_PNMFileTypePNM(const FactoryParams ¶ms);
00079
00080 public:
00081 static TypeHandle get_class_type() {
00082 return _type_handle;
00083 }
00084 static void init_type() {
00085 PNMFileType::init_type();
00086 register_type(_type_handle, "PNMFileTypePNM",
00087 PNMFileType::get_class_type());
00088 }
00089 virtual TypeHandle get_type() const {
00090 return get_class_type();
00091 }
00092 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00093
00094 private:
00095 static TypeHandle _type_handle;
00096 };
00097
00098 #endif // HAVE_PNM
00099
00100 #endif
00101
00102