Panda3D
Loading...
Searching...
No Matches
pnmWriter.I
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 pnmWriter.I
10 * @author drose
11 * @date 2000-06-16
12 */
13
14/**
15 *
16 */
17INLINE PNMWriter::
18PNMWriter(PNMFileType *type, std::ostream *file, bool owns_file) :
19 _type(type),
20 _owns_file(owns_file),
21 _file(file),
22 _is_valid(true)
23{
24}
25
26/**
27 * Returns a pointer to the PNMFileType object that created this PNMWriter.
28 */
30get_type() const {
31 return _type;
32}
33
34/**
35 *
36 */
37INLINE void PNMWriter::
38set_color_type(ColorType type) {
39 set_num_channels((int)type);
40}
41
42/**
43 *
44 */
45INLINE void PNMWriter::
46set_num_channels(int num_channels) {
47 nassertv(num_channels >= 1 && num_channels <= 4);
48 _num_channels = num_channels;
49}
50
51/**
52 *
53 */
54INLINE void PNMWriter::
55set_maxval(xelval maxval) {
56 _maxval = maxval;
57}
58
59/**
60 *
61 */
62INLINE void PNMWriter::
63set_x_size(int x_size) {
64 nassertv(x_size >= 0);
65 _x_size = x_size;
66}
67
68/**
69 *
70 */
71INLINE void PNMWriter::
72set_y_size(int y_size) {
73 nassertv(y_size >= 0);
74 _y_size = y_size;
75}
76
77/**
78 * Initializes all the data in the header (x_size, y_size, num_channels, etc.)
79 * to the same values indicated in the given header. This should be done
80 * before writing anything to the file.
81 */
82INLINE void PNMWriter::
83copy_header_from(const PNMImageHeader &header) {
84 PNMImageHeader::operator = (header);
85}
86
87/**
88 * Returns true if the PNMWriter can be used to write data, false if something
89 * is wrong.
90 */
91INLINE bool PNMWriter::
92is_valid() const {
93 return _is_valid;
94}
This is the base class of a family of classes that represent particular image file types that PNMImag...
Definition pnmFileType.h:32
This is the base class of PNMImage, PNMReader, and PNMWriter.
bool is_valid() const
Returns true if the PNMWriter can be used to write data, false if something is wrong.
Definition pnmWriter.I:92
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:83
PNMFileType * get_type() const
Returns a pointer to the PNMFileType object that created this PNMWriter.
Definition pnmWriter.I:30