Panda3D
 All Classes Functions Variables Enumerations
pnmFileTypeIMG.h
1 // Filename: pnmFileTypeIMG.h
2 // Created by: drose (17Jun00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef PNMFILETYPEIMG_H
16 #define PNMFILETYPEIMG_H
17 
18 #include "pandabase.h"
19 
20 #ifdef HAVE_IMG
21 
22 #include "pnmFileType.h"
23 #include "pnmReader.h"
24 #include "pnmWriter.h"
25 
26 ////////////////////////////////////////////////////////////////////
27 // Class : PNMFileTypeIMG
28 // Description : For reading and writing headerless R,G,B files.
29 ////////////////////////////////////////////////////////////////////
30 class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeIMG : public PNMFileType {
31 public:
32  PNMFileTypeIMG();
33 
34  virtual string get_name() const;
35 
36  virtual int get_num_extensions() const;
37  virtual string get_extension(int n) const;
38  virtual string get_suggested_extension() const;
39 
40  virtual PNMReader *make_reader(istream *file, bool owns_file = true,
41  const string &magic_number = string());
42  virtual PNMWriter *make_writer(ostream *file, bool owns_file = true);
43 
44 public:
45  class Reader : public PNMReader {
46  public:
47  Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number);
48 
49  virtual bool supports_read_row() const;
50  virtual bool read_row(xel *array, xelval *alpha, int x_size, int y_size);
51  };
52 
53  class Writer : public PNMWriter {
54  public:
55  Writer(PNMFileType *type, ostream *file, bool owns_file);
56 
57  virtual bool supports_write_row() const;
58  virtual bool write_header();
59  virtual bool write_row(xel *array, xelval *alpha);
60  };
61 
62 
63  // The TypedWritable interface follows.
64 public:
65  static void register_with_read_factory();
66 
67 protected:
68  static TypedWritable *make_PNMFileTypeIMG(const FactoryParams &params);
69 
70 public:
71  static TypeHandle get_class_type() {
72  return _type_handle;
73  }
74  static void init_type() {
75  PNMFileType::init_type();
76  register_type(_type_handle, "PNMFileTypeIMG",
77  PNMFileType::get_class_type());
78  }
79  virtual TypeHandle get_type() const {
80  return get_class_type();
81  }
82  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
83 
84 private:
85  static TypeHandle _type_handle;
86 };
87 
88 #endif // HAVE_IMG
89 
90 #endif
91 
92 
virtual string get_extension(int n) const
Returns the nth possible filename extension associated with this particular file type, without a leading dot.
Definition: pnmFileType.cxx:62
virtual PNMWriter * make_writer(ostream *file, bool owns_file=true)
Allocates and returns a new PNMWriter suitable for reading from this file type, if possible...
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This is the base class of a family of classes that represent particular image file types that PNMImag...
Definition: pnmFileType.h:35
virtual int get_num_extensions() const
Returns the number of different possible filename extensions associated with this particular file typ...
Definition: pnmFileType.cxx:50
virtual PNMReader * make_reader(istream *file, bool owns_file=true, const string &magic_number=string())
Allocates and returns a new PNMReader suitable for reading from this file type, if possible...
virtual string get_suggested_extension() const
Returns a suitable filename extension (without a leading dot) to suggest for files of this type...
Definition: pnmFileType.cxx:75
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
This is an abstract base class that defines the interface for reading image files of various types...
Definition: pnmReader.h:31
This is an abstract base class that defines the interface for writing image files of various types...
Definition: pnmWriter.h:31
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85