18 #include "pandabase.h"
20 #include "pnmImageHeader.h"
22 #include "stackedPerlinNoise2.h"
23 #include "convert_srgb.h"
72 INLINE PNMImage(
int x_size,
int y_size,
int num_channels = 3,
74 ColorSpace color_space = CS_linear);
75 INLINE PNMImage(
const PNMImage ©);
76 INLINE
void operator = (
const PNMImage ©);
80 INLINE xelval clamp_val(
int input_value)
const;
81 INLINE xelval to_val(
float input_value)
const;
82 INLINE xelval to_alpha_val(
float input_value)
const;
83 INLINE
float from_val(xelval input_value)
const;
84 INLINE
float from_alpha_val(xelval input_value)
const;
87 void clear(
int x_size,
int y_size,
int num_channels = 3,
89 ColorSpace color_space = CS_linear);
91 void copy_from(
const PNMImage ©);
92 void copy_channel(
const PNMImage ©,
int src_channel,
int dest_channel);
94 void take_from(PNMImage &orig);
96 INLINE
void fill(
float red,
float green,
float blue);
97 INLINE
void fill(
float gray = 0.0);
99 void fill_val(xelval red, xelval green, xelval blue);
100 INLINE
void fill_val(xelval gray = 0);
102 INLINE
void alpha_fill(
float alpha = 0.0);
103 void alpha_fill_val(xelval alpha = 0);
105 INLINE
void set_read_size(
int x_size,
int y_size);
106 INLINE
void clear_read_size();
107 INLINE
bool has_read_size()
const;
108 INLINE
int get_read_x_size()
const;
109 INLINE
int get_read_y_size()
const;
113 bool report_unknown_type =
true);
114 BLOCKING
bool read(istream &data,
const string &filename =
string(),
116 bool report_unknown_type =
true);
120 BLOCKING
bool write(ostream &data,
const string &filename =
string(),
122 BLOCKING
bool write(
PNMWriter *writer)
const;
124 INLINE
bool is_valid()
const;
126 INLINE
void set_num_channels(
int num_channels);
127 void set_color_type(ColorType color_type);
128 void set_color_space(ColorSpace color_space);
130 INLINE
void add_alpha();
131 INLINE
void remove_alpha();
132 INLINE
void make_grayscale();
133 void make_grayscale(
float rc,
float gc,
float bc);
134 INLINE
void make_rgb();
136 void premultiply_alpha();
137 void unpremultiply_alpha();
139 BLOCKING
void reverse_rows();
140 BLOCKING
void flip(
bool flip_x,
bool flip_y,
bool transpose);
142 BLOCKING
void set_maxval(xelval maxval);
150 INLINE
xel &get_xel_val(
int x,
int y);
151 INLINE
xel get_xel_val(
int x,
int y)
const;
152 INLINE
void set_xel_val(
int x,
int y,
const xel &value);
153 INLINE
void set_xel_val(
int x,
int y, xelval r, xelval g, xelval b);
154 INLINE
void set_xel_val(
int x,
int y, xelval gray);
156 INLINE xelval get_red_val(
int x,
int y)
const;
157 INLINE xelval get_green_val(
int x,
int y)
const;
158 INLINE xelval get_blue_val(
int x,
int y)
const;
159 INLINE xelval get_gray_val(
int x,
int y)
const;
160 INLINE xelval get_alpha_val(
int x,
int y)
const;
162 INLINE
void set_red_val(
int x,
int y, xelval r);
163 INLINE
void set_green_val(
int x,
int y, xelval g);
164 INLINE
void set_blue_val(
int x,
int y, xelval b);
165 INLINE
void set_gray_val(
int x,
int y, xelval gray);
166 INLINE
void set_alpha_val(
int x,
int y, xelval a);
168 xelval get_channel_val(
int x,
int y,
int channel)
const;
169 void set_channel_val(
int x,
int y,
int channel, xelval value);
170 float get_channel(
int x,
int y,
int channel)
const;
171 void set_channel(
int x,
int y,
int channel,
float value);
180 INLINE
LRGBColorf get_xel(
int x,
int y)
const;
181 INLINE
void set_xel(
int x,
int y,
const LRGBColorf &value);
182 INLINE
void set_xel(
int x,
int y,
float r,
float g,
float b);
183 INLINE
void set_xel(
int x,
int y,
float gray);
185 INLINE
LColorf get_xel_a(
int x,
int y)
const;
186 INLINE
void set_xel_a(
int x,
int y,
const LColorf &value);
187 INLINE
void set_xel_a(
int x,
int y,
float r,
float g,
float b,
float a);
189 INLINE
float get_red(
int x,
int y)
const;
190 INLINE
float get_green(
int x,
int y)
const;
191 INLINE
float get_blue(
int x,
int y)
const;
192 INLINE
float get_gray(
int x,
int y)
const;
193 INLINE
float get_alpha(
int x,
int y)
const;
195 INLINE
void set_red(
int x,
int y,
float r);
196 INLINE
void set_green(
int x,
int y,
float g);
197 INLINE
void set_blue(
int x,
int y,
float b);
198 INLINE
void set_gray(
int x,
int y,
float gray);
199 INLINE
void set_alpha(
int x,
int y,
float a);
201 INLINE
float get_bright(
int x,
int y)
const;
202 INLINE
float get_bright(
int x,
int y,
float rc,
float gc,
204 INLINE
float get_bright(
int x,
int y,
float rc,
float gc,
205 float bc,
float ac)
const;
207 INLINE
void blend(
int x,
int y,
const LRGBColorf &val,
float alpha);
208 void blend(
int x,
int y,
float r,
float g,
float b,
float alpha);
210 void copy_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 void blend_sub_image(
const PNMImage ©,
int xto,
int yto,
214 int xfrom = 0,
int yfrom = 0,
215 int x_size = -1,
int y_size = -1,
216 float pixel_scale = 1.0);
217 void add_sub_image(
const PNMImage ©,
int xto,
int yto,
218 int xfrom = 0,
int yfrom = 0,
219 int x_size = -1,
int y_size = -1,
220 float pixel_scale = 1.0);
221 void mult_sub_image(
const PNMImage ©,
int xto,
int yto,
222 int xfrom = 0,
int yfrom = 0,
223 int x_size = -1,
int y_size = -1,
224 float pixel_scale = 1.0);
225 void darken_sub_image(
const PNMImage ©,
int xto,
int yto,
226 int xfrom = 0,
int yfrom = 0,
227 int x_size = -1,
int y_size = -1,
228 float pixel_scale = 1.0);
229 void lighten_sub_image(
const PNMImage ©,
int xto,
int yto,
230 int xfrom = 0,
int yfrom = 0,
231 int x_size = -1,
int y_size = -1,
232 float pixel_scale = 1.0);
233 void threshold(
const PNMImage &select_image,
int channel,
float threshold,
234 const PNMImage <,
const PNMImage &ge);
235 BLOCKING
void fill_distance_inside(
const PNMImage &mask,
float threshold,
int radius,
bool shrink_from_border);
236 BLOCKING
void fill_distance_outside(
const PNMImage &mask,
float threshold,
int radius);
238 void rescale(
float min_val,
float max_val);
240 void copy_channel(
const PNMImage ©,
int xto,
int yto,
int cto,
241 int xfrom = 0,
int yfrom = 0,
int cfrom = 0,
242 int x_size = -1,
int y_size = -1);
245 float min_radius,
float max_radius);
247 void expand_border(
int left,
int right,
int bottom,
int top,
253 INLINE
void box_filter(
float radius = 1.0);
254 INLINE
void gaussian_filter(
float radius = 1.0);
256 void unfiltered_stretch_from(
const PNMImage ©);
257 void box_filter_from(
float radius,
const PNMImage ©);
258 void gaussian_filter_from(
float radius,
const PNMImage ©);
259 void quick_filter_from(
const PNMImage ©,
260 int xborder = 0,
int yborder = 0);
263 void perlin_noise_fill(
float sx,
float sy,
int table_size = 256,
264 unsigned long seed = 0);
267 void remix_channels(
const LMatrix4 &conv);
268 INLINE
void gamma_correct(
float from_gamma,
float to_gamma);
269 INLINE
void gamma_correct_alpha(
float from_gamma,
float to_gamma);
270 INLINE
void apply_exponent(
float gray_exponent);
271 INLINE
void apply_exponent(
float gray_exponent,
float alpha_exponent);
272 INLINE
void apply_exponent(
float red_exponent,
float green_exponent,
float blue_exponent);
273 void apply_exponent(
float red_exponent,
float green_exponent,
float blue_exponent,
float alpha_exponent);
276 LColorf get_average_xel_a()
const;
277 float get_average_gray()
const;
279 void do_fill_distance(
int xi,
int yi,
int d);
284 class EXPCL_PANDA_PNMIMAGE
Row {
286 INLINE
size_t size()
const;
287 INLINE
LColorf operator[](
int x)
const;
289 INLINE
void __setitem__(
int x,
const LColorf &v);
291 INLINE
xel &get_xel_val(
int x);
292 INLINE
void set_xel_val(
int x,
const xel &v);
293 INLINE xelval get_alpha_val(
int x)
const;
294 INLINE
void set_alpha_val(
int x, xelval v);
297 INLINE
Row(PNMImage &image,
int y);
306 class EXPCL_PANDA_PNMIMAGE
CRow {
308 INLINE
size_t size()
const;
309 INLINE
LColorf operator[](
int x)
const;
310 INLINE
xel get_xel_val(
int x)
const;
311 INLINE xelval get_alpha_val(
int x)
const;
314 INLINE
CRow(
const PNMImage &image,
int y);
317 const PNMImage &_image;
321 INLINE
Row operator [] (
int y);
322 INLINE
CRow operator [] (
int y)
const;
327 INLINE
xel *get_array();
328 INLINE
const xel *get_array()
const;
329 INLINE xelval *get_alpha_array();
330 INLINE
const xelval *get_alpha_array()
const;
332 INLINE
xel *take_array();
333 INLINE xelval *take_alpha_array();
334 void set_array(
xel *array);
335 void set_alpha_array(xelval *alpha);
338 INLINE
void allocate_array();
339 INLINE
void allocate_alpha();
341 INLINE
xel *row(
int row)
const;
342 INLINE xelval *alpha_row(
int row)
const;
344 INLINE
void setup_sub_image(
const PNMImage ©,
int &xto,
int &yto,
345 int &xfrom,
int &yfrom,
int &x_size,
int &y_size,
346 int &xmin,
int &ymin,
int &xmax,
int &ymax);
348 INLINE
static void compute_spot_pixel(
LColorf &c,
float d2,
349 float min_radius,
float max_radius,
353 void setup_encoding();
356 PNMImage operator ~()
const;
358 INLINE PNMImage operator + (
const PNMImage &other)
const;
359 INLINE PNMImage operator + (
const LColorf &other)
const;
360 INLINE PNMImage operator - (
const PNMImage &other)
const;
361 INLINE PNMImage operator - (
const LColorf &other)
const;
362 INLINE PNMImage operator * (
const PNMImage &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);
378 float _default_rc, _default_gc, _default_bc;
380 int _read_x_size, _read_y_size;
388 ColorSpace _color_space;
396 XE_generic_sRGB_alpha,
400 XE_uchar_sRGB_alpha_sse2,
406 #include "pnmImage.I"
This is the base class for all three-component vectors and points.
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
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 a 4-by-4 transform matrix.
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...
This is the base class for all three-component vectors and points.