00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef PNMFILETYPESOFTIMAGE_H
00020 #define PNMFILETYPESOFTIMAGE_H
00021
00022 #include "pandabase.h"
00023
00024 #include "pnmFileType.h"
00025 #include "pnmReader.h"
00026 #include "pnmWriter.h"
00027
00028
00029
00030
00031
00032 class EXPCL_PANDA PNMFileTypeSoftImage : public PNMFileType {
00033 public:
00034 PNMFileTypeSoftImage();
00035
00036 virtual string get_name() const;
00037
00038 virtual int get_num_extensions() const;
00039 virtual string get_extension(int n) const;
00040 virtual string get_suggested_extension() const;
00041
00042 virtual bool has_magic_number() const;
00043 virtual bool matches_magic_number(const string &magic_number) const;
00044
00045 virtual PNMReader *make_reader(istream *file, bool owns_file = true,
00046 const string &magic_number = string());
00047 virtual PNMWriter *make_writer(ostream *file, bool owns_file = true);
00048
00049 public:
00050 class Reader : public PNMReader {
00051 public:
00052 Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number);
00053
00054 virtual bool supports_read_row() const;
00055 virtual bool read_row(xel *array, xelval *alpha);
00056
00057 private:
00058 enum { unknown, rgb, rgba, rgb_a } soft_color;
00059 int rgb_ctype, alpha_ctype;
00060 };
00061
00062 class Writer : public PNMWriter {
00063 public:
00064 Writer(PNMFileType *type, ostream *file, bool owns_file);
00065
00066 virtual bool supports_write_row() const;
00067 virtual bool write_header();
00068 virtual bool write_row(xel *array, xelval *alpha);
00069 };
00070
00071
00072
00073 public:
00074 static void register_with_read_factory();
00075
00076 protected:
00077 static TypedWritable *make_PNMFileTypeSoftImage(const FactoryParams ¶ms);
00078
00079 public:
00080 static TypeHandle get_class_type() {
00081 return _type_handle;
00082 }
00083 static void init_type() {
00084 PNMFileType::init_type();
00085 register_type(_type_handle, "PNMFileTypeSoftImage",
00086 PNMFileType::get_class_type());
00087 }
00088 virtual TypeHandle get_type() const {
00089 return get_class_type();
00090 }
00091 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00092
00093 private:
00094 static TypeHandle _type_handle;
00095 };
00096
00097 #endif
00098
00099