Panda3D

Loading...
Searching...
No Matches
pnmReader.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file pnmReader.h
10 * @author drose
11 * @date 2000-06-14
12 */
13
14#ifndef PNMREADER_H
15#define PNMREADER_H
16
17#include "pandabase.h"
18
19#include "pnmImageHeader.h"
20 class PfmFile;
21
22/**
23 * This is an abstract base class that defines the interface for reading image
24 * files of various types. Any particular image file type that can be read
25 * must define a class that inherits from PNMReader to read it.
26 */
27 class EXPCL_PANDA_PNMIMAGE PNMReader : public PNMImageHeader {
28 protected:
29 INLINE PNMReader(PNMFileType *type, std::istream *file, bool owns_file);
30
31 public:
32 virtual ~PNMReader();
33 INLINE void set_read_size(int x_size, int y_size);
34
35 INLINE PNMFileType *get_type() const;
36
37 virtual void prepare_read();
38 virtual bool is_floating_point();
39 virtual bool read_pfm(PfmFile &pfm);
40 virtual int read_data(xel *array, xelval *alpha);
41 virtual bool supports_read_row() const;
42 virtual bool read_row(xel *array, xelval *alpha, int x_size, int y_size);
43
44 virtual bool supports_stream_read() const;
45
46 INLINE bool is_valid() const;
47
48 private:
49 int get_reduction_shift(int orig_size, int new_size);
50
51 protected:
52 PNMFileType *_type;
53 bool _owns_file;
54 std::istream *_file;
55 bool _is_valid;
56
57 int _read_x_size, _read_y_size;
58 bool _has_read_size;
59
60 int _x_shift, _y_shift;
61 int _orig_x_size, _orig_y_size;
62};
63
64#include "pnmReader.I"
65
66#endif
PNMFileType
This is the base class of a family of classes that represent particular image file types that PNMImag...
Definition pnmFileType.h:32
PNMImageHeader::get_type
get_type
If the file type is known (e.g.
Definition pnmImageHeader.h:85
PNMReader::read_row
virtual bool read_row(xel *array, xelval *alpha, int x_size, int y_size)
If supports_read_row(), above, returns true, this function may be called repeatedly to read the image...
Definition pnmReader.cxx:224
PNMReader::read_data
virtual int read_data(xel *array, xelval *alpha)
Reads in an entire image all at once, storing it in the pre-allocated _x_size * _y_size array and alp...
Definition pnmReader.cxx:94
PNMReader::is_floating_point
virtual bool is_floating_point()
Returns true if this PNMFileType represents a floating-point image type, false if it is a normal,...
Definition pnmReader.cxx:71
PNMReader::prepare_read
virtual void prepare_read()
This method will be called before read_data() or read_row() is called.
Definition pnmReader.cxx:44
PNMReader::supports_stream_read
virtual bool supports_stream_read() const
Returns true if this particular PNMReader can read from a general stream (including pipes,...
Definition pnmReader.cxx:235
PNMReader::supports_read_row
virtual bool supports_read_row() const
Returns true if this particular PNMReader is capable of returning the data one row at a time,...
Definition pnmReader.cxx:207
PNMReader::is_valid
bool is_valid() const
Returns true if the PNMReader can be used to read data, false if something is wrong.
Definition pnmReader.I:53
PNMReader::set_read_size
void set_read_size(int x_size, int y_size)
Instructs the reader to attempt to scale the image to the indicated size while reading it.
Definition pnmReader.I:34
PNMReader::read_pfm
virtual bool read_pfm(PfmFile &pfm)
Reads floating-point data directly into the indicated PfmFile.
Definition pnmReader.cxx:80
PfmFile
Defines a pfm file, a 2-d table of floating-point numbers, either 3-component or 1-component,...
Definition pfmFile.h:31
array
STL class.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pnmImageHeader.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pnmReader.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.