58 INLINE ColorType get_color_type()
const;
59 INLINE
int get_num_channels()
const;
60 MAKE_PROPERTY(num_channels, get_num_channels);
62 INLINE
static bool is_grayscale(ColorType color_type);
63 INLINE
bool is_grayscale()
const;
65 INLINE
static bool has_alpha(ColorType color_type);
66 INLINE
bool has_alpha()
const;
68 INLINE xelval get_maxval()
const;
69 INLINE ColorSpace get_color_space()
const;
70 MAKE_PROPERTY(maxval, get_maxval);
71 MAKE_PROPERTY(color_space, get_color_space);
73 INLINE
int get_x_size()
const;
74 INLINE
int get_y_size()
const;
75 INLINE LVecBase2i get_size()
const;
76 MAKE_PROPERTY(size, get_size);
78 INLINE std::string get_comment()
const;
79 INLINE
void set_comment(
const std::string &comment);
80 MAKE_PROPERTY(comment, get_comment, set_comment);
82 INLINE
bool has_type()
const;
85 MAKE_PROPERTY2(type, has_type, get_type);
88 bool report_unknown_type =
true);
89 BLOCKING
bool read_header(std::istream &data,
const std::string &filename = std::string(),
90 PNMFileType *type =
nullptr,
bool report_unknown_type =
true);
94 bool report_unknown_type =
true)
const;
95 PNMReader *make_reader(std::istream *file,
bool owns_file =
true,
97 std::string magic_number = std::string(),
99 bool report_unknown_type =
true)
const;
103 PNMWriter *make_writer(std::ostream *file,
bool owns_file =
true,
107 static bool read_magic_number(std::istream *file, std::string &magic_number,
110 void output(std::ostream &out)
const;
121 INLINE
PixelSpec(xelval gray_value, xelval alpha);
122 INLINE
PixelSpec(xelval red, xelval green, xelval blue);
123 INLINE
PixelSpec(xelval red, xelval green, xelval blue, xelval alpha);
127 INLINE
bool operator < (
const PixelSpec &other)
const;
128 INLINE
bool operator == (
const PixelSpec &other)
const;
129 INLINE
bool operator != (
const PixelSpec &other)
const;
132 INLINE xelval get_red()
const;
133 INLINE xelval get_green()
const;
134 INLINE xelval get_blue()
const;
135 INLINE xelval get_alpha()
const;
137 INLINE
void set_red(xelval red);
138 INLINE
void set_green(xelval green);
139 INLINE
void set_blue(xelval blue);
140 INLINE
void set_alpha(xelval alpha);
142 INLINE xelval operator [](
int n)
const;
143 INLINE
static int size();
145 void output(std::ostream &out)
const;
148 xelval _red, _green, _blue, _alpha;
171 INLINE
int get_num_pixels()
const;
172 INLINE
const PixelSpec &get_pixel(
int n)
const;
173 INLINE
int get_count(
int n)
const;
175 MAKE_SEQ(get_pixels, get_num_pixels, get_pixel);
177 void write(std::ostream &out)
const;
188 bool compute_histogram(
HistMap &hist,
xel *array, xelval *alpha,
190 bool compute_palette(
Palette &palette,
xel *array, xelval *alpha,
194 int _x_size, _y_size;
197 ColorSpace _color_space;
198 std::string _comment;