Panda3D
|
00001 // Filename: pnmFileTypeIMG.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 PNMFILETYPEIMG_H 00016 #define PNMFILETYPEIMG_H 00017 00018 #include "pandabase.h" 00019 00020 #ifdef HAVE_IMG 00021 00022 #include "pnmFileType.h" 00023 #include "pnmReader.h" 00024 #include "pnmWriter.h" 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Class : PNMFileTypeIMG 00028 // Description : For reading and writing headerless R,G,B files. 00029 //////////////////////////////////////////////////////////////////// 00030 class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeIMG : public PNMFileType { 00031 public: 00032 PNMFileTypeIMG(); 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 PNMReader *make_reader(istream *file, bool owns_file = true, 00041 const string &magic_number = string()); 00042 virtual PNMWriter *make_writer(ostream *file, bool owns_file = true); 00043 00044 public: 00045 class Reader : public PNMReader { 00046 public: 00047 Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number); 00048 00049 virtual bool supports_read_row() const; 00050 virtual bool read_row(xel *array, xelval *alpha, int x_size, int y_size); 00051 }; 00052 00053 class Writer : public PNMWriter { 00054 public: 00055 Writer(PNMFileType *type, ostream *file, bool owns_file); 00056 00057 virtual bool supports_write_row() const; 00058 virtual bool write_header(); 00059 virtual bool write_row(xel *array, xelval *alpha); 00060 }; 00061 00062 00063 // The TypedWritable interface follows. 00064 public: 00065 static void register_with_read_factory(); 00066 00067 protected: 00068 static TypedWritable *make_PNMFileTypeIMG(const FactoryParams ¶ms); 00069 00070 public: 00071 static TypeHandle get_class_type() { 00072 return _type_handle; 00073 } 00074 static void init_type() { 00075 PNMFileType::init_type(); 00076 register_type(_type_handle, "PNMFileTypeIMG", 00077 PNMFileType::get_class_type()); 00078 } 00079 virtual TypeHandle get_type() const { 00080 return get_class_type(); 00081 } 00082 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00083 00084 private: 00085 static TypeHandle _type_handle; 00086 }; 00087 00088 #endif // HAVE_IMG 00089 00090 #endif 00091 00092