Panda3D
|
The name of this class derives from the fact that we originally implemented it as a layer on top of the "pnm library", based on netpbm, which was built to implement pbm, pgm, and pbm files, and is the underlying support of a number of public-domain image file converters. More...
#include "pnmImage.h"
Public Member Functions | |
PNMImage (const Filename &filename, PNMFileType *type=NULL) | |
PNMImage (const PNMImage ©) | |
PNMImage (int x_size, int y_size, int num_channels=3, xelval maxval=255, PNMFileType *type=NULL) | |
void | add_alpha () |
Adds an alpha channel to the image, if it does not already have one. | |
void | alpha_fill (double alpha=0.0) |
Sets the entire alpha channel to the given level. | |
void | alpha_fill_val (xelval alpha=0) |
Sets the entire alpha channel to the given level. | |
void | apply_exponent (double gray_exponent) |
Adjusts each channel of the image by raising the corresponding component value to the indicated exponent, such that L' = L ^ exponent. | |
void | apply_exponent (double gray_exponent, double alpha_exponent) |
Adjusts each channel of the image by raising the corresponding component value to the indicated exponent, such that L' = L ^ exponent. | |
void | apply_exponent (double red_exponent, double green_exponent, double blue_exponent) |
Adjusts each channel of the image by raising the corresponding component value to the indicated exponent, such that L' = L ^ exponent. | |
void | apply_exponent (double red_exponent, double green_exponent, double blue_exponent, double alpha_exponent) |
Adjusts each channel of the image by raising the corresponding component value to the indicated exponent, such that L' = L ^ exponent. | |
void | blend (int x, int y, const LRGBColord &val, double alpha) |
Smoothly blends the indicated pixel value in with whatever was already in the image, based on the given alpha value. | |
void | blend (int x, int y, double r, double g, double b, double alpha) |
Smoothly blends the indicated pixel value in with whatever was already in the image, based on the given alpha value. | |
void | blend_sub_image (const PNMImage ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1, double pixel_scale=1.0) |
Behaves like copy_sub_image(), except the alpha channel of the copy is used to blend the copy into the destination image, instead of overwriting pixels unconditionally. | |
void | box_filter (double radius=1.0) |
This flavor of box_filter() will apply the filter over the entire image without resizing or copying; the effect is that of a blur operation. | |
void | box_filter_from (double radius, const PNMImage ©) |
Makes a resized copy of the indicated image into this one using the indicated filter. | |
xelval | clamp_val (int input_value) const |
A handy function to clamp values to [0..get_maxval()]. | |
void | clear () |
Frees all memory allocated for the image, and clears all its parameters (size, color, type, etc). | |
void | clear (int x_size, int y_size, int num_channels=3, xelval maxval=255, PNMFileType *type=NULL) |
This flavor of clear() reinitializes the image to an empty (black) image with the given dimensions. | |
void | clear_read_size () |
Undoes the effect of a previous call to set_read_size(). | |
void | copy_channel (const PNMImage ©, int xto, int yto, int cto, int xfrom=0, int yfrom=0, int cfrom=0, int x_size=-1, int y_size=-1) |
Copies just a single channel from the source image into a single channel of this image, leaving the remaining channels alone. | |
void | copy_channel (const PNMImage ©, int src_channel, int dest_channel) |
Copies a channel from one image into another. | |
void | copy_from (const PNMImage ©) |
Makes this image become a copy of the other image. | |
void | copy_header_from (const PNMImageHeader &header) |
Copies just the header information into this image. | |
void | copy_sub_image (const PNMImage ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1) |
Copies a rectangular area of another image into a rectangular area of this image. | |
void | darken_sub_image (const PNMImage ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1, double pixel_scale=1.0) |
Behaves like copy_sub_image(), but the resulting color will be the darker of the source and destination colors at each pixel (and at each R, G, B, A component value). | |
void | expand_border (int left, int right, int bottom, int top, const LColord &color) |
Expands the image by the indicated number of pixels on each edge. | |
void | fill (double red, double green, double blue) |
Sets the entire image (except the alpha channel) to the given color. | |
void | fill (double gray=0.0) |
Sets the entire image (except the alpha channel) to the given grayscale level. | |
void | fill_val (xelval red, xelval green, xelval blue) |
Sets the entire image (except the alpha channel) to the given color. | |
void | fill_val (xelval gray=0) |
Sets the entire image (except the alpha channel) to the given grayscale level. | |
double | from_val (xelval input_value) const |
A handy function to scale values from [0..get_maxval()] to [0..1]. | |
void | gamma_correct (double from_gamma, double to_gamma) |
Assuming the image was constructed with a gamma curve of from_gamma in the RGB channels, converts it to an image with a gamma curve of to_gamma in the RGB channels. | |
void | gamma_correct_alpha (double from_gamma, double to_gamma) |
Assuming the image was constructed with a gamma curve of from_gamma in the alpha channel, converts it to an image with a gamma curve of to_gamma in the alpha channel. | |
void | gaussian_filter (double radius=1.0) |
This flavor of gaussian_filter() will apply the filter over the entire image without resizing or copying; the effect is that of a blur operation. | |
void | gaussian_filter_from (double radius, const PNMImage ©) |
Makes a resized copy of the indicated image into this one using the indicated filter. | |
double | get_alpha (int x, int y) const |
Returns the alpha component color at the indicated pixel. | |
xelval | get_alpha_val (int x, int y) const |
Returns the alpha component color at the indicated pixel. | |
double | get_average_gray () const |
Returns the average grayscale component of all of the pixels in the image. | |
LRGBColord | get_average_xel () const |
Returns the average color of all of the pixels in the image. | |
LColord | get_average_xel_a () const |
Returns the average color of all of the pixels in the image, including the alpha channel. | |
double | get_blue (int x, int y) const |
Returns the blue component color at the indicated pixel. | |
xelval | get_blue_val (int x, int y) const |
Returns the blue component color at the indicated pixel. | |
double | get_bright (int x, int y, double rc, double gc, double bc) const |
This flavor of get_bright() works correctly only for color images. | |
double | get_bright (int x, int y) const |
Returns the linear brightness of the given xel, as a double in the range 0..1. | |
double | get_bright (int x, int y, double rc, double gc, double bc, double ac) const |
This flavor of get_bright() works correctly only for four-channel images. | |
double | get_channel (int x, int y, int channel) const |
Returns the nth component color at the indicated pixel. | |
xelval | get_channel_val (int x, int y, int channel) const |
Returns the nth component color at the indicated pixel. | |
double | get_gray (int x, int y) const |
Returns the gray component color at the indicated pixel. | |
xelval | get_gray_val (int x, int y) const |
Returns the gray component color at the indicated pixel. | |
double | get_green (int x, int y) const |
Returns the green component color at the indicated pixel. | |
xelval | get_green_val (int x, int y) const |
Returns the green component color at the indicated pixel. | |
PixelSpec | get_pixel (int x, int y) const |
Returns the (r, g, b, a) pixel value at the indicated pixel, using a PixelSpec object. | |
int | get_read_x_size () const |
Returns the requested x_size of the image if set_read_size() has been called, or the image x_size otherwise (if it is known). | |
int | get_read_y_size () const |
Returns the requested y_size of the image if set_read_size() has been called, or the image y_size otherwise (if it is known). | |
double | get_red (int x, int y) const |
Returns the red component color at the indicated pixel. | |
xelval | get_red_val (int x, int y) const |
Returns the red component color at the indicated pixel. | |
LRGBColord | get_xel (int x, int y) const |
Returns the RGB color at the indicated pixel. | |
LColord | get_xel_a (int x, int y) const |
Returns the RGBA color at the indicated pixel. | |
const xel & | get_xel_val (int x, int y) const |
Returns the RGB color at the indicated pixel. | |
bool | has_read_size () const |
Returns true if set_read_size() has been called. | |
bool | is_valid () const |
Returns true if the image has been read in or correctly initialized with a height and width. | |
void | lighten_sub_image (const PNMImage ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1, double pixel_scale=1.0) |
Behaves like copy_sub_image(), but the resulting color will be the lighter of the source and destination colors at each pixel (and at each R, G, B, A component value). | |
void | make_grayscale () |
Converts the image from RGB to grayscale. | |
void | make_grayscale (double rc, double gc, double bc) |
Converts the image from RGB to grayscale. | |
void | make_histogram (Histogram &hist) |
Computes a histogram of the colors used in the image. | |
void | make_rgb () |
Converts the image from grayscale to RGB. | |
PNMImage | operator* (double multiplier) const |
Multiplies every pixel value in the image by a constant floating-point multiplier value. | |
PNMImage | operator* (const PNMImage &other) const |
Returns a new PNMImage in which each pixel value from the left image is multiplied by each pixel value from the right image. | |
void | operator*= (const PNMImage &other) |
Returns a new PNMImage in which each pixel value from the left image is multiplied by each pixel value from the right image. | |
void | operator*= (double multiplier) |
Multiplies every pixel value in the image by a constant floating-point multiplier value. | |
PNMImage | operator+ (const LColord &other) const |
Returns a new PNMImage in which the provided color is added to each pixel in the provided image. | |
PNMImage | operator+ (const PNMImage &other) const |
Returns a new PNMImage in which each pixel value is the sum of the corresponding pixel values in the two given images. | |
void | operator+= (const LColord &other) |
Returns a new PNMImage in which the provided color is added to each pixel in the provided image. | |
void | operator+= (const PNMImage &other) |
Returns a new PNMImage in which each pixel value is the sum of the corresponding pixel values in the two given images. | |
PNMImage | operator- (const LColord &other) const |
Returns a new PNMImage in which the provided color is subtracted from each pixel in the provided image. | |
PNMImage | operator- (const PNMImage &other) const |
Returns a new PNMImage in which each pixel value from the right image is subtracted from each pixel value from the left image. | |
void | operator-= (const PNMImage &other) |
Returns a new PNMImage in which each pixel value from the right image is subtracted from each pixel value from the left image. | |
void | operator-= (const LColord &other) |
Returns a new PNMImage in which the provided color is subtracted from each pixel in the provided image. | |
void | operator= (const PNMImage ©) |
xel * | operator[] (int y) |
Allows the PNMImage to appear to be a 2-d array of xels. | |
const xel * | operator[] (int y) const |
Allows the PNMImage to appear to be a 2-d array of xels. | |
PNMImage | operator~ () const |
Returns a new PNMImage that is the complement of the current PNMImage. | |
void | perlin_noise_fill (double sx, double sy, int table_size=256, unsigned long seed=0) |
Fills the image with a grayscale perlin noise pattern based on the indicated parameters. | |
void | perlin_noise_fill (StackedPerlinNoise2 &perlin) |
Variant of perlin_noise_fill that uses an existing StackedPerlinNoise2 object. | |
void | quick_filter_from (const PNMImage ©, int xborder=0, int yborder=0) |
Resizes from the given image, with a fixed radius of 0.5. | |
bool | read (istream &data, const string &filename=string(), PNMFileType *type=NULL, bool report_unknown_type=true) |
Reads the image data from the indicated stream. | |
bool | read (PNMReader *reader) |
This flavor of read() uses an already-existing PNMReader to read the image file. | |
bool | read (const Filename &filename, PNMFileType *type=NULL, bool report_unknown_type=true) |
Reads the indicated image filename. | |
void | remix_channels (const LMatrix4 &conv) |
Transforms every pixel using the operation (Ro,Go,Bo) = conv.xform_point(Ri,Gi,Bi); Input must be a color image. | |
void | remove_alpha () |
Removes the image's alpha channel, if it exists. | |
void | render_spot (const LColord &fg, const LColord &bg, double min_radius, double max_radius) |
Renders a solid-color circle, with a fuzzy edge, into the center of the PNMImage. | |
void | reverse_rows () |
Performs an in-place reversal of the row (y) data. | |
void | set_alpha (int x, int y, double a) |
Sets the alpha component color only at the indicated pixel. | |
void | set_alpha_val (int x, int y, xelval a) |
Sets the alpha component color only at the indicated pixel. | |
void | set_blue (int x, int y, double b) |
Sets the blue component color only at the indicated pixel. | |
void | set_blue_val (int x, int y, xelval b) |
Sets the blue component color only at the indicated pixel. | |
void | set_channel (int x, int y, int channel, double value) |
Sets the nth component color at the indicated pixel. | |
void | set_channel_val (int x, int y, int channel, xelval value) |
Sets the nth component color at the indicated pixel. | |
void | set_color_type (ColorType color_type) |
Translates the image to or from grayscale, color, or four-color mode. | |
void | set_gray (int x, int y, double gray) |
Sets the gray component color at the indicated pixel. | |
void | set_gray_val (int x, int y, xelval gray) |
Sets the gray component color at the indicated pixel. | |
void | set_green (int x, int y, double g) |
Sets the green component color only at the indicated pixel. | |
void | set_green_val (int x, int y, xelval g) |
Sets the green component color only at the indicated pixel. | |
void | set_maxval (xelval maxval) |
Rescales the image to the indicated maxval. | |
void | set_num_channels (int num_channels) |
Changes the number of channels associated with the image. | |
void | set_pixel (int x, int y, const PixelSpec &pixel) |
Sets the (r, g, b, a) pixel value at the indicated pixel, using a PixelSpec object. | |
void | set_read_size (int x_size, int y_size) |
Specifies the size to we'd like to scale the image upon reading it. | |
void | set_red (int x, int y, double r) |
Sets the red component color only at the indicated pixel. | |
void | set_red_val (int x, int y, xelval r) |
Sets the red component color only at the indicated pixel. | |
void | set_xel (int x, int y, const LRGBColord &value) |
Changes the RGB color at the indicated pixel. | |
void | set_xel (int x, int y, double r, double g, double b) |
Changes the RGB color at the indicated pixel. | |
void | set_xel (int x, int y, double gray) |
Changes all three color components at the indicated pixel to the same value. | |
void | set_xel_a (int x, int y, double r, double g, double b, double a) |
Changes the RGBA color at the indicated pixel. | |
void | set_xel_a (int x, int y, const LColord &value) |
Changes the RGBA color at the indicated pixel. | |
void | set_xel_val (int x, int y, const xel &value) |
Changes the RGB color at the indicated pixel. | |
void | set_xel_val (int x, int y, xelval r, xelval g, xelval b) |
Changes the RGB color at the indicated pixel. | |
void | set_xel_val (int x, int y, xelval gray) |
Changes all three color components at the indicated pixel to the same value. | |
void | take_from (PNMImage &orig) |
Move the contents of the other image into this one, and empty the other image. | |
void | threshold (const PNMImage &select_image, int channel, double threshold, const PNMImage <, const PNMImage &ge) |
Selectively copies each pixel from either one source or another source, depending on the pixel value of the indicated channel of select_image. | |
xelval | to_val (double input_value) const |
A handy function to scale values from [0..1] to [0..get_maxval()]. | |
bool | write (PNMWriter *writer) const |
This flavor of write() uses an already-existing PNMWriter to write the image file. | |
bool | write (const Filename &filename, PNMFileType *type=NULL) const |
Writes the image to the indicated filename. | |
bool | write (ostream &data, const string &filename=string(), PNMFileType *type=NULL) const |
Writes the image to the indicated ostream. |
The name of this class derives from the fact that we originally implemented it as a layer on top of the "pnm library", based on netpbm, which was built to implement pbm, pgm, and pbm files, and is the underlying support of a number of public-domain image file converters.
Nowadays we are no longer derived directly from the pnm library, mainly to allow support of C++ iostreams instead of the C stdio FILE interface.
Conceptually, a PNMImage is a two-dimensional array of xels, which are the PNM-defined generic pixel type. Each xel may have a red, green, and blue component, or (if the image is grayscale) a gray component. The image may be read in, the individual xels manipulated, and written out again, or a black image may be constructed from scratch.
The image is of size XSize() by YSize() xels, numbered from top to bottom, left to right, beginning at zero.
Files can be specified by filename, or by an iostream pointer. The filename "-" refers to stdin or stdout.
Definition at line 57 of file pnmImage.h.
void PNMImage::add_alpha | ( | ) | [inline] |
Adds an alpha channel to the image, if it does not already have one.
The alpha channel is initialized to zeros.
Definition at line 257 of file pnmImage.I.
References PNMImageHeader::is_grayscale(), and set_color_type().
Referenced by alpha_fill_val(), Texture::do_read_one(), and ImageFile::read().
void PNMImage::alpha_fill | ( | double | alpha = 0.0 | ) | [inline] |
Sets the entire alpha channel to the given level.
Definition at line 150 of file pnmImage.I.
References alpha_fill_val(), and to_val().
Referenced by Texture::do_read_one(), and expand_border().
void PNMImage::alpha_fill_val | ( | xelval | alpha = 0 | ) |
Sets the entire alpha channel to the given level.
Definition at line 215 of file pnmImage.cxx.
References add_alpha(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), PNMImageHeader::has_alpha(), is_valid(), and set_alpha_val().
Referenced by alpha_fill().
void PNMImage::apply_exponent | ( | double | gray_exponent | ) | [inline] |
Adjusts each channel of the image by raising the corresponding component value to the indicated exponent, such that L' = L ^ exponent.
Definition at line 871 of file pnmImage.I.
Referenced by apply_exponent(), gamma_correct(), and gamma_correct_alpha().
void PNMImage::apply_exponent | ( | double | gray_exponent, |
double | alpha_exponent | ||
) | [inline] |
Adjusts each channel of the image by raising the corresponding component value to the indicated exponent, such that L' = L ^ exponent.
Definition at line 883 of file pnmImage.I.
References apply_exponent().
void PNMImage::apply_exponent | ( | double | red_exponent, |
double | green_exponent, | ||
double | blue_exponent | ||
) | [inline] |
Adjusts each channel of the image by raising the corresponding component value to the indicated exponent, such that L' = L ^ exponent.
For a grayscale image, the blue_exponent value is used for the grayscale value, and red_exponent and green_exponent are unused.
Definition at line 898 of file pnmImage.I.
References apply_exponent().
void PNMImage::apply_exponent | ( | double | red_exponent, |
double | green_exponent, | ||
double | blue_exponent, | ||
double | alpha_exponent | ||
) |
Adjusts each channel of the image by raising the corresponding component value to the indicated exponent, such that L' = L ^ exponent.
For a grayscale image, the blue_exponent value is used for the grayscale value, and red_exponent and green_exponent are unused.
Definition at line 1347 of file pnmImage.cxx.
References get_alpha(), get_gray(), get_xel(), get_xel_a(), PNMImageHeader::has_alpha(), set_alpha(), set_gray(), set_xel(), and set_xel_a().
void PNMImage::blend | ( | int | x, |
int | y, | ||
const LRGBColord & | val, | ||
double | alpha | ||
) | [inline] |
Smoothly blends the indicated pixel value in with whatever was already in the image, based on the given alpha value.
An alpha of 1.0 is fully opaque and completely replaces whatever was there previously; alpha of 0.0 is fully transparent and does nothing.
Definition at line 787 of file pnmImage.I.
Referenced by blend_sub_image().
void PNMImage::blend | ( | int | x, |
int | y, | ||
double | r, | ||
double | g, | ||
double | b, | ||
double | alpha | ||
) |
Smoothly blends the indicated pixel value in with whatever was already in the image, based on the given alpha value.
An alpha of 1.0 is fully opaque and completely replaces whatever was there previously; alpha of 0.0 is fully transparent and does nothing.
Definition at line 686 of file pnmImage.cxx.
References get_alpha(), get_blue(), get_green(), get_red(), get_xel(), PNMImageHeader::has_alpha(), set_alpha(), and set_xel().
void PNMImage::blend_sub_image | ( | const PNMImage & | copy, |
int | xto, | ||
int | yto, | ||
int | xfrom = 0 , |
||
int | yfrom = 0 , |
||
int | x_size = -1 , |
||
int | y_size = -1 , |
||
double | pixel_scale = 1.0 |
||
) |
Behaves like copy_sub_image(), except the alpha channel of the copy is used to blend the copy into the destination image, instead of overwriting pixels unconditionally.
If pixel_scale is not 1.0, it specifies an amount to scale each *alpha* value of the source image before applying it to the target image.
If pixel_scale is 1.0 and the copy has no alpha channel, this degenerates into copy_sub_image().
Definition at line 789 of file pnmImage.cxx.
References blend(), copy_sub_image(), get_alpha(), get_xel(), and PNMImageHeader::has_alpha().
void PNMImage::box_filter | ( | double | radius = 1.0 | ) | [inline] |
This flavor of box_filter() will apply the filter over the entire image without resizing or copying; the effect is that of a blur operation.
Definition at line 821 of file pnmImage.I.
References box_filter_from().
void PNMImage::box_filter_from | ( | double | width, |
const PNMImage & | copy | ||
) |
Makes a resized copy of the indicated image into this one using the indicated filter.
The image to be copied is squashed and stretched to match the dimensions of the current image, applying the appropriate filter to perform the stretching.
Definition at line 442 of file pnm-image-filter.cxx.
Referenced by box_filter().
xelval PNMImage::clamp_val | ( | int | input_value | ) | const [inline] |
A handy function to clamp values to [0..get_maxval()].
Definition at line 85 of file pnmImage.I.
References PNMImageHeader::get_maxval().
Referenced by operator*=(), operator+=(), operator-=(), and to_val().
void PNMImage::clear | ( | ) |
Frees all memory allocated for the image, and clears all its parameters (size, color, type, etc).
Definition at line 49 of file pnmImage.cxx.
Referenced by clear(), GeoMipTerrain::clear_color_map(), copy_from(), copy_header_from(), read(), TextureImage::release_source_image(), and take_from().
void PNMImage::clear | ( | int | x_size, |
int | y_size, | ||
int | num_channels = 3 , |
||
xelval | maxval = 255 , |
||
PNMFileType * | type = NULL |
||
) |
This flavor of clear() reinitializes the image to an empty (black) image with the given dimensions.
Definition at line 74 of file pnmImage.cxx.
References clear(), and PNMImageHeader::has_alpha().
void PNMImage::clear_read_size | ( | ) | [inline] |
Undoes the effect of a previous call to set_read_size().
Definition at line 183 of file pnmImage.I.
Referenced by GeoMipTerrain::set_heightfield().
void PNMImage::copy_channel | ( | const PNMImage & | copy, |
int | src_channel, | ||
int | dest_channel | ||
) |
Copies a channel from one image into another.
Images must be the same size
Definition at line 123 of file pnmImage.cxx.
References PNMImageHeader::get_x_size(), get_xel_a(), PNMImageHeader::get_y_size(), is_valid(), and set_xel_a().
void PNMImage::copy_channel | ( | const PNMImage & | copy, |
int | xto, | ||
int | yto, | ||
int | cto, | ||
int | xfrom = 0 , |
||
int | yfrom = 0 , |
||
int | cfrom = 0 , |
||
int | x_size = -1 , |
||
int | y_size = -1 |
||
) |
Copies just a single channel from the source image into a single channel of this image, leaving the remaining channels alone.
Definition at line 1092 of file pnmImage.cxx.
References get_alpha_val(), get_blue_val(), get_channel(), get_channel_val(), PNMImageHeader::get_maxval(), set_alpha_val(), set_blue_val(), set_channel(), and set_channel_val().
void PNMImage::copy_from | ( | const PNMImage & | copy | ) |
Makes this image become a copy of the other image.
Definition at line 104 of file pnmImage.cxx.
References clear(), copy_header_from(), PNMImageHeader::has_alpha(), and is_valid().
void PNMImage::copy_header_from | ( | const PNMImageHeader & | header | ) |
Copies just the header information into this image.
This will blow away any image data stored in the image. The new image data will be allocated, but left unitialized.
Definition at line 158 of file pnmImage.cxx.
References clear(), and PNMImageHeader::has_alpha().
Referenced by copy_from(), read(), and GeoMipTerrain::set_heightfield().
void PNMImage::copy_sub_image | ( | const PNMImage & | copy, |
int | xto, | ||
int | yto, | ||
int | xfrom = 0 , |
||
int | yfrom = 0 , |
||
int | x_size = -1 , |
||
int | y_size = -1 |
||
) |
Copies a rectangular area of another image into a rectangular area of this image.
Both images must already have been initialized. The upper-left corner of the region in both images is specified, and the size of the area; if the size is omitted, it defaults to the entire other image, or the largest piece that will fit.
Definition at line 731 of file pnmImage.cxx.
References get_alpha(), get_alpha_val(), PNMImageHeader::get_maxval(), get_xel(), get_xel_val(), PNMImageHeader::has_alpha(), set_alpha(), set_alpha_val(), set_xel(), and set_xel_val().
Referenced by blend_sub_image(), Texture::do_read_one(), and expand_border().
void PNMImage::darken_sub_image | ( | const PNMImage & | copy, |
int | xto, | ||
int | yto, | ||
int | xfrom = 0 , |
||
int | yfrom = 0 , |
||
int | x_size = -1 , |
||
int | y_size = -1 , |
||
double | pixel_scale = 1.0 |
||
) |
Behaves like copy_sub_image(), but the resulting color will be the darker of the source and destination colors at each pixel (and at each R, G, B, A component value).
If pixel_scale is not 1.0, it specifies an amount to scale each pixel value of the source image before applying it to the target image. The scale is applied with the center at 1.0: scaling the pixel value smaller brings it closer to 1.0.
Definition at line 834 of file pnmImage.cxx.
References get_alpha(), get_alpha_val(), PNMImageHeader::get_maxval(), get_xel(), get_xel_val(), PNMImageHeader::has_alpha(), set_alpha(), set_alpha_val(), set_xel(), and set_xel_val().
void PNMImage::expand_border | ( | int | left, |
int | right, | ||
int | bottom, | ||
int | top, | ||
const LColord & | color | ||
) |
Expands the image by the indicated number of pixels on each edge.
The new pixels are set to the indicated color.
If any of the values is negative, this actually crops the image.
Definition at line 1234 of file pnmImage.cxx.
References alpha_fill(), copy_sub_image(), fill(), PNMImageHeader::get_maxval(), PNMImageHeader::get_num_channels(), PNMImageHeader::get_type(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), PNMImageHeader::has_alpha(), and take_from().
void PNMImage::fill | ( | double | red, |
double | green, | ||
double | blue | ||
) | [inline] |
Sets the entire image (except the alpha channel) to the given color.
Definition at line 118 of file pnmImage.I.
References fill_val(), and to_val().
Referenced by DestTextureImage::copy(), Texture::do_read_one(), expand_border(), and fill().
void PNMImage::fill | ( | double | gray = 0.0 | ) | [inline] |
Sets the entire image (except the alpha channel) to the given grayscale level.
Definition at line 129 of file pnmImage.I.
References fill().
void PNMImage::fill_val | ( | xelval | red, |
xelval | green, | ||
xelval | blue | ||
) |
Sets the entire image (except the alpha channel) to the given color.
Definition at line 199 of file pnmImage.cxx.
References PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), is_valid(), and set_xel_val().
Referenced by fill(), and fill_val().
void PNMImage::fill_val | ( | xelval | gray = 0 | ) | [inline] |
Sets the entire image (except the alpha channel) to the given grayscale level.
Definition at line 140 of file pnmImage.I.
References fill_val().
double PNMImage::from_val | ( | xelval | input_value | ) | const [inline] |
A handy function to scale values from [0..get_maxval()] to [0..1].
Definition at line 107 of file pnmImage.I.
References PNMImageHeader::get_maxval().
Referenced by get_alpha(), get_blue(), get_bright(), get_channel(), get_gray(), get_green(), get_red(), get_xel(), get_xel_a(), and operator*=().
void PNMImage::gamma_correct | ( | double | from_gamma, |
double | to_gamma | ||
) | [inline] |
Assuming the image was constructed with a gamma curve of from_gamma in the RGB channels, converts it to an image with a gamma curve of to_gamma in the RGB channels.
Does not affect the alpha channel.
Definition at line 846 of file pnmImage.I.
References apply_exponent().
void PNMImage::gamma_correct_alpha | ( | double | from_gamma, |
double | to_gamma | ||
) | [inline] |
Assuming the image was constructed with a gamma curve of from_gamma in the alpha channel, converts it to an image with a gamma curve of to_gamma in the alpha channel.
Does not affect the RGB channels.
Definition at line 859 of file pnmImage.I.
References apply_exponent().
void PNMImage::gaussian_filter | ( | double | radius = 1.0 | ) | [inline] |
This flavor of gaussian_filter() will apply the filter over the entire image without resizing or copying; the effect is that of a blur operation.
Definition at line 833 of file pnmImage.I.
References gaussian_filter_from().
Referenced by GeoMipTerrain::calc_ambient_occlusion().
void PNMImage::gaussian_filter_from | ( | double | width, |
const PNMImage & | copy | ||
) |
Makes a resized copy of the indicated image into this one using the indicated filter.
The image to be copied is squashed and stretched to match the dimensions of the current image, applying the appropriate filter to perform the stretching.
Definition at line 456 of file pnm-image-filter.cxx.
Referenced by gaussian_filter().
double PNMImage::get_alpha | ( | int | x, |
int | y | ||
) | const [inline] |
Returns the alpha component color at the indicated pixel.
It is an error to call this unless has_alpha() is true. The value returned is a double in the range 0..1.
Definition at line 631 of file pnmImage.I.
References from_val(), and get_alpha_val().
Referenced by apply_exponent(), blend(), blend_sub_image(), copy_sub_image(), osxGraphicsPipe::create_cg_image(), darken_sub_image(), Texture::do_read_one(), lighten_sub_image(), PNMTextGlyph::place(), ImageFile::read(), and threshold().
xelval PNMImage::get_alpha_val | ( | int | x, |
int | y | ||
) | const [inline] |
Returns the alpha component color at the indicated pixel.
It is an error to call this unless has_alpha() is true. The value returned is in the range 0..maxval.
Definition at line 399 of file pnmImage.I.
Referenced by copy_channel(), copy_sub_image(), darken_sub_image(), get_alpha(), get_bright(), get_channel_val(), get_pixel(), get_xel_a(), lighten_sub_image(), set_maxval(), threshold(), and ImageFile::write().
double PNMImage::get_average_gray | ( | ) | const |
Returns the average grayscale component of all of the pixels in the image.
Definition at line 1508 of file pnmImage.cxx.
References get_gray().
LRGBColord PNMImage::get_average_xel | ( | ) | const |
Returns the average color of all of the pixels in the image.
Definition at line 1460 of file pnmImage.cxx.
References get_xel(), and LVecBase3d::zero().
LColord PNMImage::get_average_xel_a | ( | ) | const |
Returns the average color of all of the pixels in the image, including the alpha channel.
Definition at line 1484 of file pnmImage.cxx.
References get_xel_a(), and LVecBase4d::zero().
double PNMImage::get_blue | ( | int | x, |
int | y | ||
) | const [inline] |
Returns the blue component color at the indicated pixel.
The value returned is a double in the range 0..1.
Definition at line 603 of file pnmImage.I.
References from_val(), and get_blue_val().
Referenced by blend(), osxGraphicsPipe::create_cg_image(), PNMTextGlyph::get_value(), and remix_channels().
xelval PNMImage::get_blue_val | ( | int | x, |
int | y | ||
) | const [inline] |
Returns the blue component color at the indicated pixel.
The value returned is in the range 0..maxval.
Definition at line 371 of file pnmImage.I.
References get_xel_val().
Referenced by copy_channel(), get_blue(), get_bright(), get_channel_val(), get_xel(), get_xel_a(), and set_maxval().
double PNMImage::get_bright | ( | int | x, |
int | y | ||
) | const [inline] |
Returns the linear brightness of the given xel, as a double in the range 0..1.
This flavor of get_bright() returns the correct grayscale brightness level for both full-color and grayscale images.
Definition at line 742 of file pnmImage.I.
Referenced by make_grayscale(), and set_color_type().
double PNMImage::get_bright | ( | int | x, |
int | y, | ||
double | rc, | ||
double | gc, | ||
double | bc, | ||
double | ac | ||
) | const [inline] |
This flavor of get_bright() works correctly only for four-channel images.
It returns a single brightness value for the RGBA color at the indicated pixel, based on the supplied weights for each component.
Definition at line 770 of file pnmImage.I.
References from_val(), get_alpha_val(), get_blue_val(), get_green_val(), and get_red_val().
double PNMImage::get_bright | ( | int | x, |
int | y, | ||
double | rc, | ||
double | gc, | ||
double | bc | ||
) | const [inline] |
This flavor of get_bright() works correctly only for color images.
It returns a single brightness value for the RGB color at the indicated pixel, based on the supplied weights for each component.
Definition at line 755 of file pnmImage.I.
References from_val(), get_blue_val(), get_green_val(), and get_red_val().
double PNMImage::get_channel | ( | int | x, |
int | y, | ||
int | channel | ||
) | const [inline] |
Returns the nth component color at the indicated pixel.
The channel index should be in the range 0..(get_num_channels()-1). The channels are ordered B, G, R, A. This is slightly less optimal than accessing the component values directly by named methods. The value returned is a double in the range 0..1.
Definition at line 713 of file pnmImage.I.
References from_val(), and get_channel_val().
Referenced by copy_channel().
xelval PNMImage::get_channel_val | ( | int | x, |
int | y, | ||
int | channel | ||
) | const |
Returns the nth component color at the indicated pixel.
The channel index should be in the range 0..(get_num_channels()-1). The channels are ordered B, G, R, A. This is slightly less optimal than accessing the component values directly by named methods. The value returned is in the range 0..maxval.
Definition at line 576 of file pnmImage.cxx.
References get_alpha_val(), get_blue_val(), get_green_val(), PNMImageHeader::get_num_channels(), and get_red_val().
Referenced by copy_channel(), Texture::do_read_one(), get_channel(), ImageFile::read(), and threshold().
double PNMImage::get_gray | ( | int | x, |
int | y | ||
) | const [inline] |
Returns the gray component color at the indicated pixel.
This only has a meaningful value for grayscale images; for other image types, this returns the value of the blue channel only. However, also see the get_bright() function. The value returned is a double in the range 0..1.
Definition at line 618 of file pnmImage.I.
References from_val(), and get_gray_val().
Referenced by apply_exponent(), GeoMipTerrain::calc_ambient_occlusion(), osxGraphicsPipe::create_cg_image(), Texture::do_read_one(), get_average_gray(), HeightfieldTesselator::get_elevation(), and ImageFile::read().
xelval PNMImage::get_gray_val | ( | int | x, |
int | y | ||
) | const [inline] |
Returns the gray component color at the indicated pixel.
This only has a meaningful value for grayscale images; for other image types, this returns the value of the blue channel only. However, also see the get_bright() function. The value returned is in the range 0..maxval.
Definition at line 386 of file pnmImage.I.
References get_xel_val().
Referenced by get_gray(), get_pixel(), set_color_type(), set_maxval(), and write().
double PNMImage::get_green | ( | int | x, |
int | y | ||
) | const [inline] |
Returns the green component color at the indicated pixel.
The value returned is a double in the range 0..1.
Definition at line 591 of file pnmImage.I.
References from_val(), and get_green_val().
Referenced by blend(), osxGraphicsPipe::create_cg_image(), and remix_channels().
xelval PNMImage::get_green_val | ( | int | x, |
int | y | ||
) | const [inline] |
Returns the green component color at the indicated pixel.
The value returned is in the range 0..maxval.
Definition at line 360 of file pnmImage.I.
References get_xel_val().
Referenced by get_bright(), get_channel_val(), get_green(), get_xel(), get_xel_a(), and set_maxval().
PNMImage::PixelSpec PNMImage::get_pixel | ( | int | x, |
int | y | ||
) | const |
Returns the (r, g, b, a) pixel value at the indicated pixel, using a PixelSpec object.
Definition at line 645 of file pnmImage.cxx.
References get_alpha_val(), get_gray_val(), and get_xel_val().
int PNMImage::get_read_x_size | ( | ) | const [inline] |
Returns the requested x_size of the image if set_read_size() has been called, or the image x_size otherwise (if it is known).
Definition at line 205 of file pnmImage.I.
References PNMImageHeader::get_x_size().
Referenced by Texture::do_read_one().
int PNMImage::get_read_y_size | ( | ) | const [inline] |
Returns the requested y_size of the image if set_read_size() has been called, or the image y_size otherwise (if it is known).
Definition at line 217 of file pnmImage.I.
References PNMImageHeader::get_y_size().
Referenced by Texture::do_read_one().
double PNMImage::get_red | ( | int | x, |
int | y | ||
) | const [inline] |
Returns the red component color at the indicated pixel.
The value returned is a double in the range 0..1.
Definition at line 579 of file pnmImage.I.
References from_val(), and get_red_val().
Referenced by blend(), osxGraphicsPipe::create_cg_image(), and remix_channels().
xelval PNMImage::get_red_val | ( | int | x, |
int | y | ||
) | const [inline] |
Returns the red component color at the indicated pixel.
The value returned is in the range 0..maxval.
Definition at line 349 of file pnmImage.I.
References get_xel_val().
Referenced by get_bright(), get_channel_val(), PNMTextGlyph::get_interior_flag(), get_red(), get_xel(), get_xel_a(), and set_maxval().
LRGBColord PNMImage::get_xel | ( | int | x, |
int | y | ||
) | const [inline] |
Returns the RGB color at the indicated pixel.
Each component is a double in the range 0..1.
Definition at line 482 of file pnmImage.I.
References from_val(), get_blue_val(), get_green_val(), and get_red_val().
Referenced by apply_exponent(), blend(), blend_sub_image(), copy_sub_image(), darken_sub_image(), get_average_xel(), lighten_sub_image(), PNMTextGlyph::place(), ImageTransformColors::process_image(), and threshold().
LColord PNMImage::get_xel_a | ( | int | x, |
int | y | ||
) | const [inline] |
Returns the RGBA color at the indicated pixel.
Each component is a double in the range 0..1.
Definition at line 529 of file pnmImage.I.
References from_val(), get_alpha_val(), get_blue_val(), get_green_val(), get_red_val(), and PNMImageHeader::has_alpha().
Referenced by apply_exponent(), copy_channel(), get_average_xel_a(), and STBasicTerrain::read_height_map().
const xel & PNMImage::get_xel_val | ( | int | x, |
int | y | ||
) | const [inline] |
Returns the RGB color at the indicated pixel.
Each component is in the range 0..maxval.
Definition at line 300 of file pnmImage.I.
Referenced by copy_sub_image(), darken_sub_image(), get_blue_val(), get_gray_val(), get_green_val(), get_pixel(), get_red_val(), lighten_sub_image(), and threshold().
bool PNMImage::has_read_size | ( | ) | const [inline] |
Returns true if set_read_size() has been called.
Definition at line 193 of file pnmImage.I.
Referenced by read().
bool PNMImage::is_valid | ( | ) | const [inline] |
Returns true if the image has been read in or correctly initialized with a height and width.
If this returns false, virtually all member functions except clear() and read() are invalid function calls.
Definition at line 230 of file pnmImage.I.
Referenced by alpha_fill_val(), DestTextureImage::copy(), copy_channel(), copy_from(), TexturePlacement::fill_image(), TexturePlacement::fill_swapped_image(), fill_val(), PNMTextGlyph::place(), STBasicTerrain::read_height_map(), and write().
void PNMImage::lighten_sub_image | ( | const PNMImage & | copy, |
int | xto, | ||
int | yto, | ||
int | xfrom = 0 , |
||
int | yfrom = 0 , |
||
int | x_size = -1 , |
||
int | y_size = -1 , |
||
double | pixel_scale = 1.0 |
||
) |
Behaves like copy_sub_image(), but the resulting color will be the lighter of the source and destination colors at each pixel (and at each R, G, B, A component value).
If pixel_scale is not 1.0, it specifies an amount to scale each pixel value of the source image before applying it to the target image.
Definition at line 904 of file pnmImage.cxx.
References get_alpha(), get_alpha_val(), PNMImageHeader::get_maxval(), get_xel(), get_xel_val(), PNMImageHeader::has_alpha(), set_alpha(), set_alpha_val(), set_xel(), and set_xel_val().
void PNMImage::make_grayscale | ( | ) | [inline] |
Converts the image from RGB to grayscale.
Any alpha channel, if present, is left undisturbed.
Definition at line 278 of file pnmImage.I.
Referenced by GeoMipTerrain::calc_ambient_occlusion(), and GeoMipTerrain::make_slope_image().
void PNMImage::make_grayscale | ( | double | rc, |
double | gc, | ||
double | bc | ||
) |
Converts the image from RGB to grayscale.
Any alpha channel, if present, is left undisturbed. The optional rc, gc, bc values represent the relative weights to apply to each channel to convert it to grayscale.
Definition at line 481 of file pnmImage.cxx.
References get_bright(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), PNMImageHeader::has_alpha(), PNMImageHeader::is_grayscale(), and set_gray().
void PNMImage::make_histogram | ( | PNMImage::Histogram & | histogram | ) |
Computes a histogram of the colors used in the image.
Definition at line 1255 of file pnmImage.cxx.
References PNMImageHeader::compute_histogram(), and PNMImageHeader::Histogram::swap().
void PNMImage::make_rgb | ( | ) | [inline] |
Converts the image from grayscale to RGB.
Any alpha channel, if present, is left undisturbed.
Definition at line 289 of file pnmImage.I.
References PNMImageHeader::has_alpha(), and set_color_type().
Returns a new PNMImage in which each pixel value from the left image is multiplied by each pixel value from the right image.
Note that the floating-point values in the 0..1 range are multiplied, not in the 0..maxval range. Only valid when both images have the same size.
Definition at line 1090 of file pnmImage.I.
PNMImage PNMImage::operator* | ( | double | multiplier | ) | const [inline] |
Multiplies every pixel value in the image by a constant floating-point multiplier value.
Definition at line 1103 of file pnmImage.I.
void PNMImage::operator*= | ( | const PNMImage & | other | ) |
Returns a new PNMImage in which each pixel value from the left image is multiplied by each pixel value from the right image.
Note that the floating-point values in the 0..1 range are multiplied, not in the 0..maxval range. Only valid when both images have the same size.
Definition at line 1682 of file pnmImage.cxx.
References from_val(), and to_val().
void PNMImage::operator*= | ( | double | multiplier | ) |
Multiplies every pixel value in the image by a constant floating-point multiplier value.
Definition at line 1713 of file pnmImage.cxx.
References clamp_val().
Returns a new PNMImage in which each pixel value is the sum of the corresponding pixel values in the two given images.
Only valid when both images have the same size.
Definition at line 1032 of file pnmImage.I.
Returns a new PNMImage in which the provided color is added to each pixel in the provided image.
Definition at line 1045 of file pnmImage.I.
void PNMImage::operator+= | ( | const LColord & | other | ) |
Returns a new PNMImage in which the provided color is added to each pixel in the provided image.
Definition at line 1598 of file pnmImage.cxx.
References clamp_val(), and PNMImageHeader::get_maxval().
void PNMImage::operator+= | ( | const PNMImage & | other | ) |
Returns a new PNMImage in which each pixel value is the sum of the corresponding pixel values in the two given images.
Only valid when both images have the same size.
Definition at line 1566 of file pnmImage.cxx.
References clamp_val().
Returns a new PNMImage in which the provided color is subtracted from each pixel in the provided image.
Definition at line 1073 of file pnmImage.I.
Returns a new PNMImage in which each pixel value from the right image is subtracted from each pixel value from the left image.
Only valid when both images have the same size.
Definition at line 1060 of file pnmImage.I.
void PNMImage::operator-= | ( | const LColord & | other | ) |
Returns a new PNMImage in which the provided color is subtracted from each pixel in the provided image.
Definition at line 1667 of file pnmImage.cxx.
void PNMImage::operator-= | ( | const PNMImage & | other | ) |
Returns a new PNMImage in which each pixel value from the right image is subtracted from each pixel value from the left image.
Only valid when both images have the same size.
Definition at line 1635 of file pnmImage.cxx.
References clamp_val().
const xel * PNMImage::operator[] | ( | int | y | ) | const [inline] |
Allows the PNMImage to appear to be a 2-d array of xels.
Definition at line 809 of file pnmImage.I.
xel * PNMImage::operator[] | ( | int | y | ) | [inline] |
Allows the PNMImage to appear to be a 2-d array of xels.
Definition at line 798 of file pnmImage.I.
PNMImage PNMImage::operator~ | ( | ) | const |
Returns a new PNMImage that is the complement of the current PNMImage.
Definition at line 1532 of file pnmImage.cxx.
void PNMImage::perlin_noise_fill | ( | double | sx, |
double | sy, | ||
int | table_size = 256 , |
||
unsigned long | seed = 0 |
||
) |
Fills the image with a grayscale perlin noise pattern based on the indicated parameters.
Uses set_xel to set the grayscale values. The sx and sy parameters are in multiples of the size of this image. See also the PerlinNoise2 class in mathutil.
Definition at line 1286 of file pnmImage.cxx.
References PerlinNoise2::noise(), and set_xel().
void PNMImage::perlin_noise_fill | ( | StackedPerlinNoise2 & | perlin | ) |
Variant of perlin_noise_fill that uses an existing StackedPerlinNoise2 object.
Definition at line 1305 of file pnmImage.cxx.
References StackedPerlinNoise2::noise(), and set_xel().
void PNMImage::quick_filter_from | ( | const PNMImage & | from, |
int | xborder = 0 , |
||
int | yborder = 0 |
||
) |
Resizes from the given image, with a fixed radius of 0.5.
This is a very specialized and simple algorithm that doesn't handle dropping below the Nyquist rate very well, but is quite a bit faster than the more general box_filter(), above. If borders are specified, they will further restrict the size of the resulting image. There's no point in using quick_box_filter() on a single image.
Definition at line 564 of file pnm-image-filter.cxx.
References Thread::consider_yield(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), PNMImageHeader::has_alpha(), and set_alpha_val().
Referenced by DestTextureImage::copy(), Texture::do_load_one(), Texture::do_read_one(), TexturePlacement::fill_image(), TexturePlacement::fill_swapped_image(), Texture::generate_simple_ram_image(), and read().
bool PNMImage::read | ( | PNMReader * | reader | ) |
This flavor of read() uses an already-existing PNMReader to read the image file.
You can get a reader via the PNMImageHeader::make_reader() methods. This is a good way to examine the header of a file (for instance, to determine its size) before actually reading the entire image.
The PNMReader is always deleted upon completion, whether successful or not.
Definition at line 287 of file pnmImage.cxx.
References clear(), copy_header_from(), PNMImageHeader::get_maxval(), PNMImageHeader::get_num_channels(), PNMImageHeader::get_type(), has_read_size(), PNMReader::is_valid(), PNMReader::prepare_read(), quick_filter_from(), PNMReader::read_data(), PNMReader::set_read_size(), and take_from().
bool PNMImage::read | ( | const Filename & | filename, |
PNMFileType * | type = NULL , |
||
bool | report_unknown_type = true |
||
) |
Reads the indicated image filename.
If type is non-NULL, it is a suggestion for the type of file it is. Returns true if successful, false on error.
Definition at line 237 of file pnmImage.cxx.
References clear(), and PNMImageHeader::make_reader().
Referenced by Texture::do_read_one(), osxGraphicsStateGuardian::draw_resize_box(), ImageReader::handle_args(), ImageFile::read(), read(), GeoMipTerrain::set_color_map(), HeightfieldTesselator::set_heightfield(), and GeoMipTerrain::set_heightfield().
bool PNMImage::read | ( | istream & | data, |
const string & | filename = string() , |
||
PNMFileType * | type = NULL , |
||
bool | report_unknown_type = true |
||
) |
Reads the image data from the indicated stream.
The filename is advisory only, and may be used to suggest a type if it has a known extension.
If type is non-NULL, it is a suggestion for the type of file it is (and a non-NULL type will override any magic number test or filename extension lookup).
Returns true if successful, false on error.
Definition at line 262 of file pnmImage.cxx.
References clear(), PNMImageHeader::make_reader(), and read().
void PNMImage::remix_channels | ( | const LMatrix4 & | conv | ) |
Transforms every pixel using the operation (Ro,Go,Bo) = conv.xform_point(Ri,Gi,Bi); Input must be a color image.
Definition at line 1324 of file pnmImage.cxx.
References get_blue(), get_green(), PNMImageHeader::get_num_channels(), get_red(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), set_xel(), and LMatrix4f::xform_point().
void PNMImage::remove_alpha | ( | ) | [inline] |
Removes the image's alpha channel, if it exists.
Definition at line 267 of file pnmImage.I.
References PNMImageHeader::is_grayscale(), and set_color_type().
Referenced by ImageFile::write().
void PNMImage::render_spot | ( | const LColord & | fg, |
const LColord & | bg, | ||
double | min_radius, | ||
double | max_radius | ||
) |
Renders a solid-color circle, with a fuzzy edge, into the center of the PNMImage.
If the PNMImage is non-square, this actually renders an ellipse.
The min_radius and max_radius are in the scale 0..1, where 1.0 means the full width of the image. If min_radius == max_radius, the edge is sharp (but still antialiased); otherwise, the pixels between min_radius and max_radius are smoothly blended between fg and bg colors.
Definition at line 1152 of file pnmImage.cxx.
References set_xel_a().
void PNMImage::reverse_rows | ( | ) |
Performs an in-place reversal of the row (y) data.
Definition at line 502 of file pnmImage.cxx.
void PNMImage::set_alpha | ( | int | x, |
int | y, | ||
double | r | ||
) | [inline] |
Sets the alpha component color only at the indicated pixel.
It is an error to call this unless has_alpha() is true. The value given should be in the range 0..1.
Definition at line 697 of file pnmImage.I.
References set_alpha_val(), and to_val().
Referenced by apply_exponent(), blend(), copy_sub_image(), darken_sub_image(), Texture::do_read_one(), TexturePlacement::fill_image(), TexturePlacement::fill_swapped_image(), lighten_sub_image(), PNMTextGlyph::place(), ImageFile::read(), and threshold().
void PNMImage::set_alpha_val | ( | int | x, |
int | y, | ||
xelval | a | ||
) | [inline] |
Sets the alpha component color only at the indicated pixel.
It is an error to call this unless has_alpha() is true. The value given should be in the range 0..maxval.
Definition at line 470 of file pnmImage.I.
Referenced by alpha_fill_val(), copy_channel(), copy_sub_image(), darken_sub_image(), TexturePlacement::flag_error_image(), lighten_sub_image(), quick_filter_from(), set_alpha(), set_channel_val(), set_maxval(), set_pixel(), set_xel_a(), and threshold().
void PNMImage::set_blue | ( | int | x, |
int | y, | ||
double | r | ||
) | [inline] |
Sets the blue component color only at the indicated pixel.
The value given should be a double in the range 0..1.
Definition at line 667 of file pnmImage.I.
References set_blue_val(), and to_val().
void PNMImage::set_blue_val | ( | int | x, |
int | y, | ||
xelval | b | ||
) | [inline] |
Sets the blue component color only at the indicated pixel.
The value given should be in the range 0..maxval.
Definition at line 438 of file pnmImage.I.
Referenced by copy_channel(), set_blue(), set_channel_val(), and set_maxval().
void PNMImage::set_channel | ( | int | x, |
int | y, | ||
int | channel, | ||
double | value | ||
) | [inline] |
Sets the nth component color at the indicated pixel.
The channel index should be in the range 0..(get_num_channels()-1). The channels are ordered B, G, R, A. This is slightly less optimal than setting the component values directly by named methods. The value given should be a double in the range 0..1.
Definition at line 729 of file pnmImage.I.
References set_channel_val(), and to_val().
Referenced by copy_channel().
void PNMImage::set_channel_val | ( | int | x, |
int | y, | ||
int | channel, | ||
xelval | value | ||
) |
Sets the nth component color at the indicated pixel.
The channel index should be in the range 0..(get_num_channels()-1). The channels are ordered B, G, R, A. This is slightly less optimal than setting the component values directly by named methods. The value given should be in the range 0..maxval.
Definition at line 611 of file pnmImage.cxx.
References set_alpha_val(), set_blue_val(), set_green_val(), and set_red_val().
Referenced by copy_channel(), and set_channel().
void PNMImage::set_color_type | ( | PNMImage::ColorType | color_type | ) |
Translates the image to or from grayscale, color, or four-color mode.
Grayscale images are converted to full-color images with R, G, B set to the original gray level; color images are converted to grayscale according to the value of Bright(). The alpha channel, if added, is initialized to zero.
Definition at line 431 of file pnmImage.cxx.
References get_bright(), PNMImageHeader::get_color_type(), get_gray_val(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), PNMImageHeader::has_alpha(), PNMImageHeader::is_grayscale(), set_gray(), and set_xel_val().
Referenced by add_alpha(), make_rgb(), remove_alpha(), and set_num_channels().
void PNMImage::set_gray | ( | int | x, |
int | y, | ||
double | r | ||
) | [inline] |
Sets the gray component color at the indicated pixel.
This is only meaningful for grayscale images; for other image types, this simply sets the blue component color. However, also see set_xel(), which can set all the component colors to the same grayscale level, and hence works correctly both for grayscale and color images. The value given should be a double in the range 0..1.
Definition at line 684 of file pnmImage.I.
References set_gray_val(), and to_val().
Referenced by apply_exponent(), make_grayscale(), and set_color_type().
void PNMImage::set_gray_val | ( | int | x, |
int | y, | ||
xelval | gray | ||
) | [inline] |
Sets the gray component color at the indicated pixel.
This is only meaningful for grayscale images; for other image types, this simply sets the blue component color. However, also see set_xel_val(), which can set all the component colors to the same grayscale level, and hence works correctly both for grayscale and color images. The value given should be in the range 0..maxval.
Definition at line 456 of file pnmImage.I.
Referenced by set_gray(), set_maxval(), and ImageFile::write().
void PNMImage::set_green | ( | int | x, |
int | y, | ||
double | r | ||
) | [inline] |
Sets the green component color only at the indicated pixel.
The value given should be a double in the range 0..1.
Definition at line 655 of file pnmImage.I.
References set_green_val(), and to_val().
void PNMImage::set_green_val | ( | int | x, |
int | y, | ||
xelval | g | ||
) | [inline] |
Sets the green component color only at the indicated pixel.
The value given should be in the range 0..maxval.
Definition at line 425 of file pnmImage.I.
Referenced by set_channel_val(), set_green(), and set_maxval().
void PNMImage::set_maxval | ( | xelval | maxval | ) |
Rescales the image to the indicated maxval.
Definition at line 530 of file pnmImage.cxx.
References get_alpha_val(), get_blue_val(), get_gray_val(), get_green_val(), get_red_val(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), PNMImageHeader::has_alpha(), PNMImageHeader::is_grayscale(), set_alpha_val(), set_blue_val(), set_gray_val(), set_green_val(), and set_red_val().
Referenced by GeoMipTerrain::calc_ambient_occlusion().
void PNMImage::set_num_channels | ( | int | num_channels | ) | [inline] |
Changes the number of channels associated with the image.
The new number of channels must be an integer in the range 1 through 4, inclusive. This will allocate and/or deallocate memory as necessary to accommodate; see set_color_type().
Definition at line 244 of file pnmImage.I.
References set_color_type().
void PNMImage::set_pixel | ( | int | x, |
int | y, | ||
const PixelSpec & | pixel | ||
) |
Sets the (r, g, b, a) pixel value at the indicated pixel, using a PixelSpec object.
Definition at line 667 of file pnmImage.cxx.
References set_alpha_val(), and set_xel_val().
void PNMImage::set_read_size | ( | int | x_size, |
int | y_size | ||
) | [inline] |
Specifies the size to we'd like to scale the image upon reading it.
This will affect the next call to read(). This is usually used to reduce the image size, e.g. for a thumbnail.
If the file type reader supports it (e.g. JPEG), then this will scale the image during the read operation, consequently reducing memory and CPU utilization. If the file type reader does not support it, this will load the image normally, and them perform a linear scale after it has been loaded.
Definition at line 170 of file pnmImage.I.
Referenced by Texture::consider_rescale(), Texture::do_read_one(), and GeoMipTerrain::set_heightfield().
void PNMImage::set_red | ( | int | x, |
int | y, | ||
double | r | ||
) | [inline] |
Sets the red component color only at the indicated pixel.
The value given should be a double in the range 0..1.
Definition at line 643 of file pnmImage.I.
References set_red_val(), and to_val().
void PNMImage::set_red_val | ( | int | x, |
int | y, | ||
xelval | r | ||
) | [inline] |
Sets the red component color only at the indicated pixel.
The value given should be in the range 0..maxval.
Definition at line 412 of file pnmImage.I.
Referenced by set_channel_val(), set_maxval(), and set_red().
void PNMImage::set_xel | ( | int | x, |
int | y, | ||
const LRGBColord & | value | ||
) | [inline] |
Changes the RGB color at the indicated pixel.
Each component is a double in the range 0..1.
Definition at line 495 of file pnmImage.I.
References set_xel_val(), and to_val().
Referenced by apply_exponent(), blend(), GeoMipTerrain::calc_ambient_occlusion(), copy_sub_image(), darken_sub_image(), TexturePlacement::fill_image(), TexturePlacement::fill_swapped_image(), lighten_sub_image(), GeoMipTerrain::make_slope_image(), perlin_noise_fill(), PNMTextGlyph::place(), ImageTransformColors::process_image(), remix_channels(), and threshold().
void PNMImage::set_xel | ( | int | x, |
int | y, | ||
double | r, | ||
double | g, | ||
double | b | ||
) | [inline] |
Changes the RGB color at the indicated pixel.
Each component is a double in the range 0..1.
Definition at line 506 of file pnmImage.I.
References set_xel_val(), and to_val().
void PNMImage::set_xel | ( | int | x, |
int | y, | ||
double | gray | ||
) | [inline] |
Changes all three color components at the indicated pixel to the same value.
The value is a double in the range 0..1.
Definition at line 518 of file pnmImage.I.
References set_xel_val(), and to_val().
void PNMImage::set_xel_a | ( | int | x, |
int | y, | ||
const LColord & | value | ||
) | [inline] |
Changes the RGBA color at the indicated pixel.
Each component is a double in the range 0..1.
Definition at line 550 of file pnmImage.I.
References PNMImageHeader::has_alpha(), set_alpha_val(), set_xel_val(), and to_val().
Referenced by apply_exponent(), copy_channel(), and render_spot().
void PNMImage::set_xel_a | ( | int | x, |
int | y, | ||
double | r, | ||
double | g, | ||
double | b, | ||
double | a | ||
) | [inline] |
Changes the RGBA color at the indicated pixel.
Each component is a double in the range 0..1.
Definition at line 564 of file pnmImage.I.
References PNMImageHeader::has_alpha(), set_alpha_val(), set_xel_val(), and to_val().
void PNMImage::set_xel_val | ( | int | x, |
int | y, | ||
const xel & | value | ||
) | [inline] |
Changes the RGB color at the indicated pixel.
Each component is in the range 0..maxval.
Definition at line 312 of file pnmImage.I.
Referenced by copy_sub_image(), darken_sub_image(), fill_val(), TexturePlacement::flag_error_image(), lighten_sub_image(), set_color_type(), set_pixel(), set_xel(), set_xel_a(), and threshold().
void PNMImage::set_xel_val | ( | int | x, |
int | y, | ||
xelval | r, | ||
xelval | g, | ||
xelval | b | ||
) | [inline] |
Changes the RGB color at the indicated pixel.
Each component is in the range 0..maxval.
Definition at line 324 of file pnmImage.I.
void PNMImage::set_xel_val | ( | int | x, |
int | y, | ||
xelval | gray | ||
) | [inline] |
Changes all three color components at the indicated pixel to the same value.
The value is in the range 0..maxval.
Definition at line 337 of file pnmImage.I.
void PNMImage::take_from | ( | PNMImage & | orig | ) |
Move the contents of the other image into this one, and empty the other image.
Definition at line 177 of file pnmImage.cxx.
References clear(), and PNMImageHeader::has_alpha().
Referenced by Texture::do_read_one(), expand_border(), and read().
void PNMImage::threshold | ( | const PNMImage & | select_image, |
int | channel, | ||
double | threshold, | ||
const PNMImage & | lt, | ||
const PNMImage & | ge | ||
) |
Selectively copies each pixel from either one source or another source, depending on the pixel value of the indicated channel of select_image.
For each pixel (x, y):
s = select_image.get_channel(x, y). Set this image's (x, y) to:
lt.get_xel(x, y) if s <= threshold, or
ge.get_xel(x, y) if s > threshold
Any of select_image, lt, or ge may be the same PNMImge object as this image, or the same as each other; or they may all be different. All images must be the same size.
Definition at line 983 of file pnmImage.cxx.
References get_alpha(), get_alpha_val(), get_channel_val(), PNMImageHeader::get_maxval(), PNMImageHeader::get_num_channels(), PNMImageHeader::get_x_size(), get_xel(), get_xel_val(), PNMImageHeader::get_y_size(), PNMImageHeader::has_alpha(), set_alpha(), set_alpha_val(), set_xel(), and set_xel_val().
xelval PNMImage::to_val | ( | double | input_value | ) | const [inline] |
A handy function to scale values from [0..1] to [0..get_maxval()].
Definition at line 96 of file pnmImage.I.
References clamp_val(), and PNMImageHeader::get_maxval().
Referenced by alpha_fill(), fill(), operator*=(), set_alpha(), set_blue(), set_channel(), set_gray(), set_green(), set_red(), set_xel(), and set_xel_a().
bool PNMImage::write | ( | ostream & | data, |
const string & | filename = string() , |
||
PNMFileType * | type = NULL |
||
) | const |
Writes the image to the indicated ostream.
The filename is advisory only, and may be used suggest a type if it has a known extension.
If type is non-NULL, it is a suggestion for the type of image file to write.
Definition at line 367 of file pnmImage.cxx.
References is_valid(), PNMImageHeader::make_writer(), and write().
bool PNMImage::write | ( | PNMWriter * | writer | ) | const |
This flavor of write() uses an already-existing PNMWriter to write the image file.
You can get a writer via the PNMImageHeader::make_writer() methods.
The PNMWriter is always deleted upon completion, whether successful or not.
Definition at line 392 of file pnmImage.cxx.
References PNMWriter::copy_header_from(), get_gray_val(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), PNMImageHeader::is_grayscale(), is_valid(), PNMWriter::supports_grayscale(), and PNMWriter::write_data().
bool PNMImage::write | ( | const Filename & | filename, |
PNMFileType * | type = NULL |
||
) | const |
Writes the image to the indicated filename.
If type is non-NULL, it is a suggestion for the type of image file to write.
Definition at line 342 of file pnmImage.cxx.
References is_valid(), and PNMImageHeader::make_writer().
Referenced by Texture::do_write_one(), DisplayRegion::save_screenshot(), ImageFile::write(), write(), and ImageWriter::write_image().