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
xel to_val(
const LRGBColorf &input_value)
const;
72 INLINE xelval to_val(
float input_value)
const;
73 INLINE xelval to_alpha_val(
float input_value)
const;
74 INLINE LRGBColorf from_val(
const xel &input_value)
const;
75 INLINE
float from_val(xelval input_value)
const;
76 INLINE
float from_alpha_val(xelval input_value)
const;
79 void clear(
int x_size,
int y_size,
int num_channels = 3,
81 ColorSpace color_space = CS_linear);
83 void copy_from(
const PNMImage ©);
84 void copy_channel(
const PNMImage ©,
int src_channel,
int dest_channel);
85 void copy_channel_bits(
const PNMImage ©,
int src_channel,
int dest_channel, xelval src_mask,
int right_shift);
89 INLINE
void fill(
float red,
float green,
float blue);
90 INLINE
void fill(
float gray = 0.0);
92 void fill_val(xelval red, xelval green, xelval blue);
93 INLINE
void fill_val(xelval gray = 0);
95 INLINE
void alpha_fill(
float alpha = 0.0);
96 void alpha_fill_val(xelval alpha = 0);
98 INLINE
void set_read_size(
int x_size,
int y_size);
99 INLINE
void clear_read_size();
100 INLINE
bool has_read_size()
const;
101 INLINE
int get_read_x_size()
const;
102 INLINE
int get_read_y_size()
const;
106 bool report_unknown_type =
true);
107 BLOCKING
bool read(std::istream &data,
const std::string &filename = std::string(),
109 bool report_unknown_type =
true);
113 BLOCKING
bool write(std::ostream &data,
const std::string &filename = std::string(),
115 BLOCKING
bool write(
PNMWriter *writer)
const;
117 INLINE
bool is_valid()
const;
119 INLINE
void set_num_channels(
int num_channels);
120 void set_color_type(ColorType color_type);
121 void set_color_space(ColorSpace color_space);
123 INLINE
void add_alpha();
124 INLINE
void remove_alpha();
125 INLINE
void make_grayscale();
126 void make_grayscale(
float rc,
float gc,
float bc);
127 INLINE
void make_rgb();
129 BLOCKING
void premultiply_alpha();
130 BLOCKING
void unpremultiply_alpha();
132 BLOCKING
void reverse_rows();
133 BLOCKING
void flip(
bool flip_x,
bool flip_y,
bool transpose);
135 BLOCKING
void set_maxval(xelval maxval);
143 INLINE
xel &get_xel_val(
int x,
int y);
144 INLINE
xel get_xel_val(
int x,
int y)
const;
145 INLINE
void set_xel_val(
int x,
int y,
const xel &value);
146 INLINE
void set_xel_val(
int x,
int y, xelval r, xelval g, xelval b);
147 INLINE
void set_xel_val(
int x,
int y, xelval gray);
149 INLINE xelval get_red_val(
int x,
int y)
const;
150 INLINE xelval get_green_val(
int x,
int y)
const;
151 INLINE xelval get_blue_val(
int x,
int y)
const;
152 INLINE xelval get_gray_val(
int x,
int y)
const;
153 INLINE xelval get_alpha_val(
int x,
int y)
const;
155 INLINE
void set_red_val(
int x,
int y, xelval r);
156 INLINE
void set_green_val(
int x,
int y, xelval g);
157 INLINE
void set_blue_val(
int x,
int y, xelval b);
158 INLINE
void set_gray_val(
int x,
int y, xelval gray);
159 INLINE
void set_alpha_val(
int x,
int y, xelval a);
161 xelval get_channel_val(
int x,
int y,
int channel)
const;
162 void set_channel_val(
int x,
int y,
int channel, xelval value);
163 float get_channel(
int x,
int y,
int channel)
const;
164 void set_channel(
int x,
int y,
int channel,
float value);
173 INLINE LRGBColorf get_xel(
int x,
int y)
const;
174 INLINE
void set_xel(
int x,
int y,
const LRGBColorf &value);
175 INLINE
void set_xel(
int x,
int y,
float r,
float g,
float b);
176 INLINE
void set_xel(
int x,
int y,
float gray);
178 INLINE LColorf get_xel_a(
int x,
int y)
const;
179 INLINE
void set_xel_a(
int x,
int y,
const LColorf &value);
180 INLINE
void set_xel_a(
int x,
int y,
float r,
float g,
float b,
float a);
182 INLINE
float get_red(
int x,
int y)
const;
183 INLINE
float get_green(
int x,
int y)
const;
184 INLINE
float get_blue(
int x,
int y)
const;
185 INLINE
float get_gray(
int x,
int y)
const;
186 INLINE
float get_alpha(
int x,
int y)
const;
188 INLINE
void set_red(
int x,
int y,
float r);
189 INLINE
void set_green(
int x,
int y,
float g);
190 INLINE
void set_blue(
int x,
int y,
float b);
191 INLINE
void set_gray(
int x,
int y,
float gray);
192 INLINE
void set_alpha(
int x,
int y,
float a);
194 INLINE
float get_bright(
int x,
int y)
const;
195 INLINE
float get_bright(
int x,
int y,
float rc,
float gc,
197 INLINE
float get_bright(
int x,
int y,
float rc,
float gc,
198 float bc,
float ac)
const;
200 INLINE
void blend(
int x,
int y,
const LRGBColorf &val,
float alpha);
201 void blend(
int x,
int y,
float r,
float g,
float b,
float alpha);
203 void copy_sub_image(
const PNMImage ©,
int xto,
int yto,
204 int xfrom = 0,
int yfrom = 0,
205 int x_size = -1,
int y_size = -1);
206 void blend_sub_image(
const PNMImage ©,
int xto,
int yto,
207 int xfrom = 0,
int yfrom = 0,
208 int x_size = -1,
int y_size = -1,
209 float pixel_scale = 1.0);
210 void add_sub_image(
const PNMImage ©,
int xto,
int yto,
211 int xfrom = 0,
int yfrom = 0,
212 int x_size = -1,
int y_size = -1,
213 float pixel_scale = 1.0);
214 void mult_sub_image(
const PNMImage ©,
int xto,
int yto,
215 int xfrom = 0,
int yfrom = 0,
216 int x_size = -1,
int y_size = -1,
217 float pixel_scale = 1.0);
218 void darken_sub_image(
const PNMImage ©,
int xto,
int yto,
219 int xfrom = 0,
int yfrom = 0,
220 int x_size = -1,
int y_size = -1,
221 float pixel_scale = 1.0);
222 void lighten_sub_image(
const PNMImage ©,
int xto,
int yto,
223 int xfrom = 0,
int yfrom = 0,
224 int x_size = -1,
int y_size = -1,
225 float pixel_scale = 1.0);
226 void threshold(
const PNMImage &select_image,
int channel,
float threshold,
228 BLOCKING
void fill_distance_inside(
const PNMImage &mask,
float threshold,
int radius,
bool shrink_from_border);
229 BLOCKING
void fill_distance_outside(
const PNMImage &mask,
float threshold,
int radius);
231 void indirect_1d_lookup(
const PNMImage &index_image,
int channel,
234 void rescale(
float min_val,
float max_val);
236 void copy_channel(
const PNMImage ©,
int xto,
int yto,
int cto,
237 int xfrom = 0,
int yfrom = 0,
int cfrom = 0,
238 int x_size = -1,
int y_size = -1);
240 void render_spot(
const LColorf &fg,
const LColorf &bg,
241 float min_radius,
float max_radius);
243 void expand_border(
int left,
int right,
int bottom,
int top,
244 const LColorf &color);
249 BLOCKING INLINE
void box_filter(
float radius = 1.0);
250 BLOCKING INLINE
void gaussian_filter(
float radius = 1.0);
252 BLOCKING
void unfiltered_stretch_from(
const PNMImage ©);
253 BLOCKING
void box_filter_from(
float radius,
const PNMImage ©);
254 BLOCKING
void gaussian_filter_from(
float radius,
const PNMImage ©);
255 BLOCKING
void quick_filter_from(
const PNMImage ©,
256 int xborder = 0,
int yborder = 0);
259 void quantize(
size_t max_colors);
260 BLOCKING
void perlin_noise_fill(
float sx,
float sy,
int table_size = 256,
261 unsigned long seed = 0);
264 void remix_channels(
const LMatrix4 &conv);
265 BLOCKING INLINE
void gamma_correct(
float from_gamma,
float to_gamma);
266 BLOCKING INLINE
void gamma_correct_alpha(
float from_gamma,
float to_gamma);
267 BLOCKING INLINE
void apply_exponent(
float gray_exponent);
268 BLOCKING INLINE
void apply_exponent(
float gray_exponent,
float alpha_exponent);
269 BLOCKING INLINE
void apply_exponent(
float red_exponent,
float green_exponent,
float blue_exponent);
270 BLOCKING
void apply_exponent(
float red_exponent,
float green_exponent,
float blue_exponent,
float alpha_exponent);
272 LRGBColorf get_average_xel()
const;
273 LColorf get_average_xel_a()
const;
274 float get_average_gray()
const;
276 void do_fill_distance(
int xi,
int yi,
int d);
281 class EXPCL_PANDA_PNMIMAGE
Row {
283 INLINE
size_t size()
const;
284 INLINE LColorf operator[](
int x)
const;
286 INLINE
void __setitem__(
int x,
const LColorf &v);
288 INLINE
xel &get_xel_val(
int x);
289 INLINE
void set_xel_val(
int x,
const xel &v);
290 INLINE xelval get_alpha_val(
int x)
const;
291 INLINE
void set_alpha_val(
int x, xelval v);
303 class EXPCL_PANDA_PNMIMAGE
CRow {
305 INLINE
size_t size()
const;
306 INLINE LColorf operator[](
int x)
const;
307 INLINE
xel get_xel_val(
int x)
const;
308 INLINE xelval get_alpha_val(
int x)
const;
318 INLINE
Row operator [] (
int y);
319 INLINE
CRow operator [] (
int y)
const;
324 INLINE
xel *get_array();
325 INLINE
const xel *get_array()
const;
326 INLINE xelval *get_alpha_array();
327 INLINE
const xelval *get_alpha_array()
const;
329 INLINE
xel *take_array();
330 INLINE xelval *take_alpha_array();
331 void set_array(
xel *array);
332 void set_alpha_array(xelval *alpha);
335 INLINE
void allocate_array();
336 INLINE
void allocate_alpha();
338 INLINE
xel *row(
int row)
const;
339 INLINE xelval *alpha_row(
int row)
const;
341 INLINE
void setup_sub_image(
const PNMImage ©,
int &xto,
int &yto,
342 int &xfrom,
int &yfrom,
int &x_size,
int &y_size,
343 int &xmin,
int &ymin,
int &xmax,
int &ymax);
345 INLINE
static void compute_spot_pixel(LColorf &c,
float d2,
346 float min_radius,
float max_radius,
347 const LColorf &fg,
const LColorf &bg);
350 void setup_encoding();
353 xel *colors,
size_t num_colors);
359 INLINE
PNMImage operator + (
const LColorf &other)
const;
361 INLINE
PNMImage operator - (
const LColorf &other)
const;
363 INLINE
PNMImage operator * (
float multiplier)
const;
364 INLINE
PNMImage operator * (
const LColorf &other)
const;
365 void operator += (
const PNMImage &other);
366 void operator += (
const LColorf &other);
367 void operator -= (
const PNMImage &other);
368 void operator -= (
const LColorf &other);
369 void operator *= (
const PNMImage &other);
370 void operator *= (
float multiplier);
371 void operator *= (
const LColorf &other);
379 float _default_rc, _default_gc, _default_bc;
381 int _read_x_size, _read_y_size;
389 ColorSpace _color_space;
397 XE_generic_sRGB_alpha,
401 XE_uchar_sRGB_alpha_sse2,
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...