Panda3D
pnmReader.h
1 // Filename: pnmReader.h
2 // Created by: drose (14Jun00)
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 PNMREADER_H
16 #define PNMREADER_H
17 
18 #include "pandabase.h"
19 
20 #include "pnmImageHeader.h"
21 class PfmFile;
22 
23 ////////////////////////////////////////////////////////////////////
24 // Class : PNMReader
25 // Description : This is an abstract base class that defines the
26 // interface for reading image files of various types.
27 // Any particular image file type that can be read must
28 // define a class that inherits from PNMReader to read
29 // it.
30 ////////////////////////////////////////////////////////////////////
31 class EXPCL_PANDA_PNMIMAGE PNMReader : public PNMImageHeader {
32 protected:
33  INLINE PNMReader(PNMFileType *type, istream *file, bool owns_file);
34 
35 public:
36  virtual ~PNMReader();
37  INLINE void set_read_size(int x_size, int y_size);
38 
39  INLINE PNMFileType *get_type() const;
40 
41  virtual void prepare_read();
42  virtual bool is_floating_point();
43  virtual bool read_pfm(PfmFile &pfm);
44  virtual int read_data(xel *array, xelval *alpha);
45  virtual bool supports_read_row() const;
46  virtual bool read_row(xel *array, xelval *alpha, int x_size, int y_size);
47 
48  virtual bool supports_stream_read() const;
49 
50  INLINE bool is_valid() const;
51 
52 private:
53  int get_reduction_shift(int orig_size, int new_size);
54 
55 protected:
56  PNMFileType *_type;
57  bool _owns_file;
58  istream *_file;
59  bool _is_valid;
60 
61  int _read_x_size, _read_y_size;
62  bool _has_read_size;
63 
64  int _x_shift, _y_shift;
65  int _orig_x_size, _orig_y_size;
66 };
67 
68 #include "pnmReader.I"
69 
70 #endif
This is the base class of a family of classes that represent particular image file types that PNMImag...
Definition: pnmFileType.h:35
Defines a pfm file, a 2-d table of floating-point numbers, either 3-component or 1-component, or with a special extension, 2- or 4-component.
Definition: pfmFile.h:34
PNMFileType * get_type() const
If the file type is known (e.g.
This is an abstract base class that defines the interface for reading image files of various types...
Definition: pnmReader.h:31
This is the base class of PNMImage, PNMReader, and PNMWriter.