62 INLINE
explicit PNMImage(
int x_size,
int y_size,
int num_channels = 3,
64 ColorSpace color_space = CS_linear);
66 INLINE
void operator = (
const PNMImage ©);
70 INLINE xelval clamp_val(
int input_value)
const;
71 INLINE xelval to_val(
float input_value)
const;
72 INLINE xelval to_alpha_val(
float input_value)
const;
73 INLINE
float from_val(xelval input_value)
const;
74 INLINE
float from_alpha_val(xelval input_value)
const;
77 void clear(
int x_size,
int y_size,
int num_channels = 3,
79 ColorSpace color_space = CS_linear);
81 void copy_from(
const PNMImage ©);
82 void copy_channel(
const PNMImage ©,
int src_channel,
int dest_channel);
83 void copy_channel_bits(
const PNMImage ©,
int src_channel,
int dest_channel, xelval src_mask,
int right_shift);
87 INLINE
void fill(
float red,
float green,
float blue);
88 INLINE
void fill(
float gray = 0.0);
90 void fill_val(xelval red, xelval green, xelval blue);
91 INLINE
void fill_val(xelval gray = 0);
93 INLINE
void alpha_fill(
float alpha = 0.0);
94 void alpha_fill_val(xelval alpha = 0);
96 INLINE
void set_read_size(
int x_size,
int y_size);
97 INLINE
void clear_read_size();
98 INLINE
bool has_read_size()
const;
99 INLINE
int get_read_x_size()
const;
100 INLINE
int get_read_y_size()
const;
101 INLINE ColorSpace get_color_space()
const;
104 bool report_unknown_type =
true);
105 BLOCKING
bool read(std::istream &data,
const std::string &filename = std::string(),
107 bool report_unknown_type =
true);
111 BLOCKING
bool write(std::ostream &data,
const std::string &filename = std::string(),
113 BLOCKING
bool write(
PNMWriter *writer)
const;
115 INLINE
bool is_valid()
const;
117 INLINE
void set_num_channels(
int num_channels);
118 void set_color_type(ColorType color_type);
119 void set_color_space(ColorSpace color_space);
121 INLINE
void add_alpha();
122 INLINE
void remove_alpha();
123 INLINE
void make_grayscale();
124 void make_grayscale(
float rc,
float gc,
float bc);
125 INLINE
void make_rgb();
127 BLOCKING
void premultiply_alpha();
128 BLOCKING
void unpremultiply_alpha();
130 BLOCKING
void reverse_rows();
131 BLOCKING
void flip(
bool flip_x,
bool flip_y,
bool transpose);
133 BLOCKING
void set_maxval(xelval maxval);
141 INLINE
xel &get_xel_val(
int x,
int y);
142 INLINE
xel get_xel_val(
int x,
int y)
const;
143 INLINE
void set_xel_val(
int x,
int y,
const xel &value);
144 INLINE
void set_xel_val(
int x,
int y, xelval r, xelval g, xelval b);
145 INLINE
void set_xel_val(
int x,
int y, xelval gray);
147 INLINE xelval get_red_val(
int x,
int y)
const;
148 INLINE xelval get_green_val(
int x,
int y)
const;
149 INLINE xelval get_blue_val(
int x,
int y)
const;
150 INLINE xelval get_gray_val(
int x,
int y)
const;
151 INLINE xelval get_alpha_val(
int x,
int y)
const;
153 INLINE
void set_red_val(
int x,
int y, xelval r);
154 INLINE
void set_green_val(
int x,
int y, xelval g);
155 INLINE
void set_blue_val(
int x,
int y, xelval b);
156 INLINE
void set_gray_val(
int x,
int y, xelval gray);
157 INLINE
void set_alpha_val(
int x,
int y, xelval a);
159 xelval get_channel_val(
int x,
int y,
int channel)
const;
160 void set_channel_val(
int x,
int y,
int channel, xelval value);
161 float get_channel(
int x,
int y,
int channel)
const;
162 void set_channel(
int x,
int y,
int channel,
float value);
171 INLINE LRGBColorf get_xel(
int x,
int y)
const;
172 INLINE
void set_xel(
int x,
int y,
const LRGBColorf &value);
173 INLINE
void set_xel(
int x,
int y,
float r,
float g,
float b);
174 INLINE
void set_xel(
int x,
int y,
float gray);
176 INLINE LColorf get_xel_a(
int x,
int y)
const;
177 INLINE
void set_xel_a(
int x,
int y,
const LColorf &value);
178 INLINE
void set_xel_a(
int x,
int y,
float r,
float g,
float b,
float a);
180 INLINE
float get_red(
int x,
int y)
const;
181 INLINE
float get_green(
int x,
int y)
const;
182 INLINE
float get_blue(
int x,
int y)
const;
183 INLINE
float get_gray(
int x,
int y)
const;
184 INLINE
float get_alpha(
int x,
int y)
const;
186 INLINE
void set_red(
int x,
int y,
float r);
187 INLINE
void set_green(
int x,
int y,
float g);
188 INLINE
void set_blue(
int x,
int y,
float b);
189 INLINE
void set_gray(
int x,
int y,
float gray);
190 INLINE
void set_alpha(
int x,
int y,
float a);
192 INLINE
float get_bright(
int x,
int y)
const;
193 INLINE
float get_bright(
int x,
int y,
float rc,
float gc,
195 INLINE
float get_bright(
int x,
int y,
float rc,
float gc,
196 float bc,
float ac)
const;
198 INLINE
void blend(
int x,
int y,
const LRGBColorf &val,
float alpha);
199 void blend(
int x,
int y,
float r,
float g,
float b,
float alpha);
201 void copy_sub_image(
const PNMImage ©,
int xto,
int yto,
202 int xfrom = 0,
int yfrom = 0,
203 int x_size = -1,
int y_size = -1);
204 void blend_sub_image(
const PNMImage ©,
int xto,
int yto,
205 int xfrom = 0,
int yfrom = 0,
206 int x_size = -1,
int y_size = -1,
207 float pixel_scale = 1.0);
208 void add_sub_image(
const PNMImage ©,
int xto,
int yto,
209 int xfrom = 0,
int yfrom = 0,
210 int x_size = -1,
int y_size = -1,
211 float pixel_scale = 1.0);
212 void mult_sub_image(
const PNMImage ©,
int xto,
int yto,
213 int xfrom = 0,
int yfrom = 0,
214 int x_size = -1,
int y_size = -1,
215 float pixel_scale = 1.0);
216 void darken_sub_image(
const PNMImage ©,
int xto,
int yto,
217 int xfrom = 0,
int yfrom = 0,
218 int x_size = -1,
int y_size = -1,
219 float pixel_scale = 1.0);
220 void lighten_sub_image(
const PNMImage ©,
int xto,
int yto,
221 int xfrom = 0,
int yfrom = 0,
222 int x_size = -1,
int y_size = -1,
223 float pixel_scale = 1.0);
224 void threshold(
const PNMImage &select_image,
int channel,
float threshold,
226 BLOCKING
void fill_distance_inside(
const PNMImage &mask,
float threshold,
int radius,
bool shrink_from_border);
227 BLOCKING
void fill_distance_outside(
const PNMImage &mask,
float threshold,
int radius);
229 void indirect_1d_lookup(
const PNMImage &index_image,
int channel,
232 void rescale(
float min_val,
float max_val);
234 void copy_channel(
const PNMImage ©,
int xto,
int yto,
int cto,
235 int xfrom = 0,
int yfrom = 0,
int cfrom = 0,
236 int x_size = -1,
int y_size = -1);
238 void render_spot(
const LColorf &fg,
const LColorf &bg,
239 float min_radius,
float max_radius);
241 void expand_border(
int left,
int right,
int bottom,
int top,
242 const LColorf &color);
247 BLOCKING INLINE
void box_filter(
float radius = 1.0);
248 BLOCKING INLINE
void gaussian_filter(
float radius = 1.0);
250 BLOCKING
void unfiltered_stretch_from(
const PNMImage ©);
251 BLOCKING
void box_filter_from(
float radius,
const PNMImage ©);
252 BLOCKING
void gaussian_filter_from(
float radius,
const PNMImage ©);
253 BLOCKING
void quick_filter_from(
const PNMImage ©,
254 int xborder = 0,
int yborder = 0);
257 BLOCKING
void perlin_noise_fill(
float sx,
float sy,
int table_size = 256,
258 unsigned long seed = 0);
261 void remix_channels(
const LMatrix4 &conv);
262 BLOCKING INLINE
void gamma_correct(
float from_gamma,
float to_gamma);
263 BLOCKING INLINE
void gamma_correct_alpha(
float from_gamma,
float to_gamma);
264 BLOCKING INLINE
void apply_exponent(
float gray_exponent);
265 BLOCKING INLINE
void apply_exponent(
float gray_exponent,
float alpha_exponent);
266 BLOCKING INLINE
void apply_exponent(
float red_exponent,
float green_exponent,
float blue_exponent);
267 BLOCKING
void apply_exponent(
float red_exponent,
float green_exponent,
float blue_exponent,
float alpha_exponent);
269 LRGBColorf get_average_xel()
const;
270 LColorf get_average_xel_a()
const;
271 float get_average_gray()
const;
273 void do_fill_distance(
int xi,
int yi,
int d);
278 class EXPCL_PANDA_PNMIMAGE
Row {
280 INLINE
size_t size()
const;
281 INLINE LColorf operator[](
int x)
const;
283 INLINE
void __setitem__(
int x,
const LColorf &v);
285 INLINE
xel &get_xel_val(
int x);
286 INLINE
void set_xel_val(
int x,
const xel &v);
287 INLINE xelval get_alpha_val(
int x)
const;
288 INLINE
void set_alpha_val(
int x, xelval v);
300 class EXPCL_PANDA_PNMIMAGE
CRow {
302 INLINE
size_t size()
const;
303 INLINE LColorf operator[](
int x)
const;
304 INLINE
xel get_xel_val(
int x)
const;
305 INLINE xelval get_alpha_val(
int x)
const;
315 INLINE
Row operator [] (
int y);
316 INLINE
CRow operator [] (
int y)
const;
321 INLINE
xel *get_array();
322 INLINE
const xel *get_array()
const;
323 INLINE xelval *get_alpha_array();
324 INLINE
const xelval *get_alpha_array()
const;
326 INLINE
xel *take_array();
327 INLINE xelval *take_alpha_array();
328 void set_array(
xel *array);
329 void set_alpha_array(xelval *alpha);
332 INLINE
void allocate_array();
333 INLINE
void allocate_alpha();
335 INLINE
xel *row(
int row)
const;
336 INLINE xelval *alpha_row(
int row)
const;
338 INLINE
void setup_sub_image(
const PNMImage ©,
int &xto,
int &yto,
339 int &xfrom,
int &yfrom,
int &x_size,
int &y_size,
340 int &xmin,
int &ymin,
int &xmax,
int &ymax);
342 INLINE
static void compute_spot_pixel(LColorf &c,
float d2,
343 float min_radius,
float max_radius,
344 const LColorf &fg,
const LColorf &bg);
347 void setup_encoding();
353 INLINE
PNMImage operator + (
const LColorf &other)
const;
355 INLINE
PNMImage operator - (
const LColorf &other)
const;
357 INLINE
PNMImage operator * (
float multiplier)
const;
358 INLINE
PNMImage operator * (
const LColorf &other)
const;
359 void operator += (
const PNMImage &other);
360 void operator += (
const LColorf &other);
361 void operator -= (
const PNMImage &other);
362 void operator -= (
const LColorf &other);
363 void operator *= (
const PNMImage &other);
364 void operator *= (
float multiplier);
365 void operator *= (
const LColorf &other);
373 float _default_rc, _default_gc, _default_bc;
375 int _read_x_size, _read_y_size;
383 ColorSpace _color_space;
391 XE_generic_sRGB_alpha,
395 XE_uchar_sRGB_alpha_sse2,
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the base class of a family of classes that represent particular image file types that PNMImag...
Implements a multi-layer PerlinNoise, with one or more high-frequency noise functions added to a lowe...
The name of a file, such as a texture file or an Egg file.
This is an abstract base class that defines the interface for reading image files of various types.
This is an abstract base class that defines the interface for writing image files of various types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.