Panda3D
 All Classes Functions Variables Enumerations
pnmWriter.I
1 // Filename: pnmWriter.I
2 // Created by: drose (16Jun00)
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 
16 ////////////////////////////////////////////////////////////////////
17 // Function: PNMWriter::Constructor
18 // Access: Protected
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE PNMWriter::
22 PNMWriter(PNMFileType *type, ostream *file, bool owns_file) :
23  _type(type),
24  _owns_file(owns_file),
25  _file(file),
26  _is_valid(true)
27 {
28 }
29 
30 ////////////////////////////////////////////////////////////////////
31 // Function: PNMWriter::get_type
32 // Access: Public
33 // Description: Returns a pointer to the PNMFileType object that
34 // created this PNMWriter.
35 ////////////////////////////////////////////////////////////////////
37 get_type() const {
38  return _type;
39 }
40 
41 ////////////////////////////////////////////////////////////////////
42 // Function: PNMWriter::set_color_type
43 // Access: Public
44 // Description:
45 ////////////////////////////////////////////////////////////////////
46 INLINE void PNMWriter::
47 set_color_type(ColorType type) {
48  set_num_channels((int)type);
49 }
50 
51 ////////////////////////////////////////////////////////////////////
52 // Function: PNMWriter::set_num_channels
53 // Access: Public
54 // Description:
55 ////////////////////////////////////////////////////////////////////
56 INLINE void PNMWriter::
57 set_num_channels(int num_channels) {
58  nassertv(num_channels >= 1 && num_channels <= 4);
59  _num_channels = num_channels;
60 }
61 
62 ////////////////////////////////////////////////////////////////////
63 // Function: PNMWriter::set_maxval
64 // Access: Public
65 // Description:
66 ////////////////////////////////////////////////////////////////////
67 INLINE void PNMWriter::
68 set_maxval(xelval maxval) {
69  _maxval = maxval;
70 }
71 
72 ////////////////////////////////////////////////////////////////////
73 // Function: PNMWriter::set_x_size
74 // Access: Public
75 // Description:
76 ////////////////////////////////////////////////////////////////////
77 INLINE void PNMWriter::
78 set_x_size(int x_size) {
79  nassertv(x_size >= 0);
80  _x_size = x_size;
81 }
82 
83 ////////////////////////////////////////////////////////////////////
84 // Function: PNMWriter::set_y_size
85 // Access: Public
86 // Description:
87 ////////////////////////////////////////////////////////////////////
88 INLINE void PNMWriter::
89 set_y_size(int y_size) {
90  nassertv(y_size >= 0);
91  _y_size = y_size;
92 }
93 
94 ////////////////////////////////////////////////////////////////////
95 // Function: PNMWriter::copy_header_from
96 // Access: Public
97 // Description: Initializes all the data in the header (x_size,
98 // y_size, num_channels, etc.) to the same values
99 // indicated in the given header. This should be done
100 // before writing anything to the file.
101 ////////////////////////////////////////////////////////////////////
102 INLINE void PNMWriter::
104  PNMImageHeader::operator = (header);
105 }
106 
107 ////////////////////////////////////////////////////////////////////
108 // Function: PNMWriter::is_valid
109 // Access: Public
110 // Description: Returns true if the PNMWriter can be used to write
111 // data, false if something is wrong.
112 ////////////////////////////////////////////////////////////////////
113 INLINE bool PNMWriter::
114 is_valid() const {
115  return _is_valid;
116 }
void copy_header_from(const PNMImageHeader &header)
Initializes all the data in the header (x_size, y_size, num_channels, etc.) to the same values indica...
Definition: pnmWriter.I:103
This is the base class of a family of classes that represent particular image file types that PNMImag...
Definition: pnmFileType.h:35
PNMFileType * get_type() const
Returns a pointer to the PNMFileType object that created this PNMWriter.
Definition: pnmWriter.I:37
bool is_valid() const
Returns true if the PNMWriter can be used to write data, false if something is wrong.
Definition: pnmWriter.I:114
This is the base class of PNMImage, PNMReader, and PNMWriter.