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"
Classes | |
class | CRow |
class | Row |
Public Member Functions | |
PNMImage (const Filename &filename, PNMFileType *type=NULL) | |
PNMImage (int x_size, int y_size, int num_channels=3, xelval maxval=255, PNMFileType *type=NULL, ColorSpace color_space=CS_linear) | |
PNMImage (const PNMImage ©) | |
void | add_alpha () |
Adds an alpha channel to the image, if it does not already have one. More... | |
void | add_sub_image (const PNMImage ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1, float pixel_scale=1.0) |
Behaves like copy_sub_image(), except the copy pixels are added to the pixels of the destination, after scaling by the specified pixel_scale. More... | |
void | alpha_fill (float alpha=0.0) |
Sets the entire alpha channel to the given level. More... | |
void | alpha_fill_val (xelval alpha=0) |
Sets the entire alpha channel to the given level. More... | |
void | apply_exponent (float gray_exponent) |
Adjusts each channel of the image by raising the corresponding component value to the indicated exponent, such that L' = L ^ exponent. More... | |
void | apply_exponent (float gray_exponent, float alpha_exponent) |
Adjusts each channel of the image by raising the corresponding component value to the indicated exponent, such that L' = L ^ exponent. More... | |
void | apply_exponent (float red_exponent, float green_exponent, float blue_exponent) |
Adjusts each channel of the image by raising the corresponding component value to the indicated exponent, such that L' = L ^ exponent. More... | |
void | apply_exponent (float red_exponent, float green_exponent, float blue_exponent, float alpha_exponent) |
Adjusts each channel of the image by raising the corresponding component value to the indicated exponent, such that L' = L ^ exponent. More... | |
void | blend (int x, int y, const LRGBColorf &val, float alpha) |
Smoothly blends the indicated pixel value in with whatever was already in the image, based on the given alpha value. More... | |
void | blend (int x, int y, float r, float g, float b, float alpha) |
Smoothly blends the indicated pixel value in with whatever was already in the image, based on the given alpha value. More... | |
void | blend_sub_image (const PNMImage ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1, float 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. More... | |
void | box_filter (float 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. More... | |
void | box_filter_from (float radius, const PNMImage ©) |
Makes a resized copy of the indicated image into this one using the indicated filter. More... | |
xelval | clamp_val (int input_value) const |
A handy function to clamp values to [0..get_maxval()]. More... | |
void | clear () |
Frees all memory allocated for the image, and clears all its parameters (size, color, type, etc). More... | |
void | clear (int x_size, int y_size, int num_channels=3, xelval maxval=255, PNMFileType *type=NULL, ColorSpace color_space=CS_linear) |
This flavor of clear() reinitializes the image to an empty (black) image with the given dimensions. More... | |
void | clear_read_size () |
Undoes the effect of a previous call to set_read_size(). More... | |
void | copy_channel (const PNMImage ©, int src_channel, int dest_channel) |
Copies a channel from one image into another. More... | |
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. More... | |
void | copy_from (const PNMImage ©) |
Makes this image become a copy of the other image. More... | |
void | copy_header_from (const PNMImageHeader &header) |
Copies just the header information into this image. More... | |
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. More... | |
void | darken_sub_image (const PNMImage ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1, float 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). More... | |
void | do_fill_distance (int xi, int yi, int d) |
Recursively fills in the minimum distance measured from a certain set of points into the gray channel. More... | |
void | expand_border (int left, int right, int bottom, int top, const LColorf &color) |
Expands the image by the indicated number of pixels on each edge. More... | |
void | fill (float red, float green, float blue) |
Sets the entire image (except the alpha channel) to the given color. More... | |
void | fill (float gray=0.0) |
Sets the entire image (except the alpha channel) to the given grayscale level. More... | |
void | fill_distance_inside (const PNMImage &mask, float threshold, int radius, bool shrink_from_border) |
Replaces this image with a grayscale image whose gray channel represents the linear Manhattan distance from the nearest dark pixel in the given mask image, up to the specified radius value (which also becomes the new maxval). More... | |
void | fill_distance_outside (const PNMImage &mask, float threshold, int radius) |
Replaces this image with a grayscale image whose gray channel represents the linear Manhattan distance from the nearest white pixel in the given mask image, up to the specified radius value (which also becomes the new maxval). More... | |
void | fill_val (xelval red, xelval green, xelval blue) |
Sets the entire image (except the alpha channel) to the given color. More... | |
void | fill_val (xelval gray=0) |
Sets the entire image (except the alpha channel) to the given grayscale level. More... | |
void | flip (bool flip_x, bool flip_y, bool transpose) |
Reverses, transposes, and/or rotates the image in-place according to the specified parameters. More... | |
float | from_alpha_val (xelval input_value) const |
A handy function to scale alpha values from [0..get_maxval()] to [0..1]. More... | |
float | from_val (xelval input_value) const |
A handy function to scale non-alpha values from [0..get_maxval()] to [0..1]. More... | |
void | gamma_correct (float from_gamma, float 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. More... | |
void | gamma_correct_alpha (float from_gamma, float 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. More... | |
void | gaussian_filter (float 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. More... | |
void | gaussian_filter_from (float radius, const PNMImage ©) |
Makes a resized copy of the indicated image into this one using the indicated filter. More... | |
float | get_alpha (int x, int y) const |
Returns the alpha component color at the indicated pixel. More... | |
xelval * | get_alpha_array () |
Directly access the underlying PNMImage array of alpha values. More... | |
const xelval * | get_alpha_array () const |
Directly access the underlying PNMImage array of alpha values. More... | |
xelval | get_alpha_val (int x, int y) const |
Returns the alpha component color at the indicated pixel. More... | |
xel * | get_array () |
Directly access the underlying PNMImage array. More... | |
const xel * | get_array () const |
Directly access the underlying PNMImage array. More... | |
float | get_average_gray () const |
Returns the average grayscale component of all of the pixels in the image. More... | |
LRGBColorf | get_average_xel () const |
Returns the average color of all of the pixels in the image. More... | |
LColorf | get_average_xel_a () const |
Returns the average color of all of the pixels in the image, including the alpha channel. More... | |
float | get_blue (int x, int y) const |
Returns the blue component color at the indicated pixel. More... | |
xelval | get_blue_val (int x, int y) const |
Returns the blue component color at the indicated pixel. More... | |
float | get_bright (int x, int y) const |
Returns the linear brightness of the given xel, as a linearized float in the range 0..1. More... | |
float | get_bright (int x, int y, float rc, float gc, float bc) const |
This flavor of get_bright() works correctly only for color images. More... | |
float | get_bright (int x, int y, float rc, float gc, float bc, float ac) const |
This flavor of get_bright() works correctly only for four-channel images. More... | |
float | get_channel (int x, int y, int channel) const |
Returns the nth component color at the indicated pixel. More... | |
xelval | get_channel_val (int x, int y, int channel) const |
Returns the nth component color at the indicated pixel. More... | |
ColorSpace | get_color_space () const |
Returns the color space in which the image is encoded. More... | |
float | get_gray (int x, int y) const |
Returns the gray component color at the indicated pixel. More... | |
xelval | get_gray_val (int x, int y) const |
Returns the gray component color at the indicated pixel. More... | |
float | get_green (int x, int y) const |
Returns the green component color at the indicated pixel. More... | |
xelval | get_green_val (int x, int y) const |
Returns the green component color at the indicated pixel. More... | |
PixelSpec | get_pixel (int x, int y) const |
Returns the (r, g, b, a) pixel value at the indicated pixel, using a PixelSpec object. More... | |
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). More... | |
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). More... | |
float | get_red (int x, int y) const |
Returns the red component color at the indicated pixel. More... | |
xelval | get_red_val (int x, int y) const |
Returns the red component color at the indicated pixel. More... | |
LRGBColorf | get_xel (int x, int y) const |
Returns the RGB color at the indicated pixel. More... | |
LColorf | get_xel_a (int x, int y) const |
Returns the RGBA color at the indicated pixel. More... | |
xel & | get_xel_val (int x, int y) |
Returns the RGB color at the indicated pixel. More... | |
xel | get_xel_val (int x, int y) const |
Returns the RGB color at the indicated pixel. More... | |
bool | has_read_size () const |
Returns true if set_read_size() has been called. More... | |
bool | is_valid () const |
Returns true if the image has been read in or correctly initialized with a height and width. More... | |
void | lighten_sub_image (const PNMImage ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1, float 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). More... | |
void | make_grayscale () |
Converts the image from RGB to grayscale. More... | |
void | make_grayscale (float rc, float gc, float bc) |
Converts the image from RGB to grayscale. More... | |
void | make_histogram (Histogram &hist) |
Computes a histogram of the colors used in the image. More... | |
void | make_rgb () |
Converts the image from grayscale to RGB. More... | |
void | mult_sub_image (const PNMImage ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1, float pixel_scale=1.0) |
Behaves like copy_sub_image(), except the copy pixels are multiplied to the pixels of the destination, after scaling by the specified pixel_scale. More... | |
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. More... | |
PNMImage | operator* (float multiplier) const |
Multiplies every pixel value in the image by a constant floating-point multiplier value. More... | |
PNMImage | operator* (const LColorf &other) const |
Returns a new PNMImage in which the provided color is multiplied to each pixel in the provided image. More... | |
void | operator*= (const PNMImage &other) |
Multiples each pixel in this image by each pixel value from the right image. More... | |
void | operator*= (float multiplier) |
Multiplies every pixel value in the image by a constant floating-point multiplier value. More... | |
void | operator*= (const LColorf &other) |
Multiplies the provided color to each pixel in this image. More... | |
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. More... | |
PNMImage | operator+ (const LColorf &other) const |
Returns a new PNMImage in which the provided color is added to each pixel in the provided image. More... | |
void | operator+= (const PNMImage &other) |
Sets each pixel value to the sum of the corresponding pixel values in the two given images. More... | |
void | operator+= (const LColorf &other) |
Adds the provided color to each pixel in this image. More... | |
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. More... | |
PNMImage | operator- (const LColorf &other) const |
Returns a new PNMImage in which the provided color is subtracted from each pixel in the provided image. More... | |
void | operator-= (const PNMImage &other) |
Subtracts each pixel from the right image from each pixel value in this image. More... | |
void | operator-= (const LColorf &other) |
Subtracts the provided color from each pixel in this image. More... | |
void | operator= (const PNMImage ©) |
Row | operator[] (int y) |
Allows the PNMImage to appear to be a 2-d array of xels. More... | |
CRow | operator[] (int y) const |
Allows the PNMImage to appear to be a 2-d array of xels. More... | |
PNMImage | operator~ () const |
Returns a new PNMImage that is the complement of this PNMImage. More... | |
void | perlin_noise_fill (float sx, float sy, int table_size=256, unsigned long seed=0) |
Fills the image with a grayscale perlin noise pattern based on the indicated parameters. More... | |
void | perlin_noise_fill (StackedPerlinNoise2 &perlin) |
Variant of perlin_noise_fill that uses an existing StackedPerlinNoise2 object. More... | |
void | premultiply_alpha () |
Converts an image in-place to its "premultiplied" form, where, for every pixel in the image, the red, green, and blue components are multiplied by that pixel's alpha value. More... | |
void | quick_filter_from (const PNMImage ©, int xborder=0, int yborder=0) |
Resizes from the given image, with a fixed radius of 0.5. More... | |
bool | read (const Filename &filename, PNMFileType *type=NULL, bool report_unknown_type=true) |
Reads the indicated image filename. More... | |
bool | read (istream &data, const string &filename=string(), PNMFileType *type=NULL, bool report_unknown_type=true) |
Reads the image data from the indicated stream. More... | |
bool | read (PNMReader *reader) |
This flavor of read() uses an already-existing PNMReader to read the image file. More... | |
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. More... | |
void | remove_alpha () |
Removes the image's alpha channel, if it exists. More... | |
void | render_spot (const LColorf &fg, const LColorf &bg, float min_radius, float max_radius) |
Renders a solid-color circle, with a fuzzy edge, into the center of the PNMImage. More... | |
void | rescale (float min_val, float max_val) |
Rescales the RGB channel values so that any values in the original image between min_val and max_val are expanded to the range 0 . More... | |
void | reverse_rows () |
Performs an in-place reversal of the row (y) data. More... | |
void | set_alpha (int x, int y, float a) |
Sets the alpha component color only at the indicated pixel. More... | |
void | set_alpha_array (xelval *alpha) |
Replaces the underlying PNMImage alpha array with the indicated pointer. More... | |
void | set_alpha_val (int x, int y, xelval a) |
Sets the alpha component color only at the indicated pixel. More... | |
void | set_array (xel *array) |
Replaces the underlying PNMImage array with the indicated pointer. More... | |
void | set_blue (int x, int y, float b) |
Sets the blue component color only at the indicated pixel. More... | |
void | set_blue_val (int x, int y, xelval b) |
Sets the blue component color only at the indicated pixel. More... | |
void | set_channel (int x, int y, int channel, float value) |
Sets the nth component color at the indicated pixel. More... | |
void | set_channel_val (int x, int y, int channel, xelval value) |
Sets the nth component color at the indicated pixel. More... | |
void | set_color_space (ColorSpace color_space) |
Converts the colors in the image to the indicated color space. More... | |
void | set_color_type (ColorType color_type) |
Translates the image to or from grayscale, color, or four-color mode. More... | |
void | set_gray (int x, int y, float gray) |
Sets the gray component color at the indicated pixel. More... | |
void | set_gray_val (int x, int y, xelval gray) |
Sets the gray component color at the indicated pixel. More... | |
void | set_green (int x, int y, float g) |
Sets the green component color only at the indicated pixel. More... | |
void | set_green_val (int x, int y, xelval g) |
Sets the green component color only at the indicated pixel. More... | |
void | set_maxval (xelval maxval) |
Rescales the image to the indicated maxval. More... | |
void | set_num_channels (int num_channels) |
Changes the number of channels associated with the image. More... | |
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. More... | |
void | set_read_size (int x_size, int y_size) |
Specifies the size to we'd like to scale the image upon reading it. More... | |
void | set_red (int x, int y, float r) |
Sets the red component color only at the indicated pixel. More... | |
void | set_red_val (int x, int y, xelval r) |
Sets the red component color only at the indicated pixel. More... | |
void | set_xel (int x, int y, const LRGBColorf &value) |
Changes the RGB color at the indicated pixel. More... | |
void | set_xel (int x, int y, float r, float g, float b) |
Changes the RGB color at the indicated pixel. More... | |
void | set_xel (int x, int y, float gray) |
Changes all three color components at the indicated pixel to the same value. More... | |
void | set_xel_a (int x, int y, const LColorf &value) |
Changes the RGBA color at the indicated pixel. More... | |
void | set_xel_a (int x, int y, float r, float g, float b, float a) |
Changes the RGBA color at the indicated pixel. More... | |
void | set_xel_val (int x, int y, const xel &value) |
Changes the RGB color at the indicated pixel. More... | |
void | set_xel_val (int x, int y, xelval r, xelval g, xelval b) |
Changes the RGB color at the indicated pixel. More... | |
void | set_xel_val (int x, int y, xelval gray) |
Changes all three color components at the indicated pixel to the same value. More... | |
xelval * | take_alpha_array () |
Returns the underlying PNMImage array and removes it from the PNMImage. More... | |
xel * | take_array () |
Returns the underlying PNMImage array and removes it from the PNMImage. More... | |
void | take_from (PNMImage &orig) |
Move the contents of the other image into this one, and empty the other image. More... | |
void | threshold (const PNMImage &select_image, int channel, float 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. More... | |
xelval | to_alpha_val (float input_value) const |
A handy function to scale alpha values from [0..1] to [0..get_maxval()]. More... | |
xelval | to_val (float input_value) const |
A handy function to scale non-alpha values from [0..1] to [0..get_maxval()]. More... | |
void | unfiltered_stretch_from (const PNMImage ©) |
Resizes from the indicated image into this one by performing a nearest-point sample. More... | |
void | unpremultiply_alpha () |
Converts an image in-place to its "straight alpha" form (presumably from a "premultiplied" form), where, for every pixel in the image, the red, green, and blue components are divided by that pixel's alpha value. More... | |
bool | write (const Filename &filename, PNMFileType *type=NULL) const |
Writes the image to the indicated filename. More... | |
bool | write (ostream &data, const string &filename=string(), PNMFileType *type=NULL) const |
Writes the image to the indicated ostream. More... | |
bool | write (PNMWriter *writer) const |
This flavor of write() uses an already-existing PNMWriter to write the image file. More... | |
![]() | |
PNMImageHeader (const PNMImageHeader ©) | |
ColorSpace | get_color_space () const |
Returns the color space that the image is encoded in, or CS_unspecified if unknown. More... | |
ColorType | get_color_type () const |
Returns the image type of the image, as an enumerated value. More... | |
string | get_comment () const |
Gets the user comment from the file. More... | |
xelval | get_maxval () const |
Returns the maximum channel value allowable for any pixel in this image; for instance, 255 for a typical 8-bit-per-channel image. More... | |
int | get_num_channels () const |
Returns the number of channels in the image. More... | |
PNMFileType * | get_type () const |
If the file type is known (e.g. More... | |
int | get_x_size () const |
Returns the number of pixels in the X direction. More... | |
int | get_y_size () const |
Returns the number of pixels in the Y direction. More... | |
bool | has_alpha () const |
Returns true if the image includes an alpha channel, false otherwise. More... | |
bool | has_type () const |
Returns true if the PNMImageHeader knows what type it is, false otherwise. More... | |
bool | is_grayscale () const |
Returns false if the image is a full-color image, and has red, green, and blue components; true if it is a grayscale image and has only a gray component. More... | |
PNMReader * | make_reader (const Filename &filename, PNMFileType *type=NULL, bool report_unknown_type=true) const |
Returns a newly-allocated PNMReader of the suitable type for reading from the indicated image filename, or NULL if the filename cannot be read for some reason. More... | |
PNMReader * | make_reader (istream *file, bool owns_file=true, const Filename &filename=Filename(), string magic_number=string(), PNMFileType *type=NULL, bool report_unknown_type=true) const |
Returns a newly-allocated PNMReader of the suitable type for reading from the already-opened image file, or NULL if the file cannot be read for some reason. More... | |
PNMWriter * | make_writer (const Filename &filename, PNMFileType *type=NULL) const |
Returns a newly-allocated PNMWriter of the suitable type for writing an image to the indicated filename, or NULL if the filename cannot be written for some reason. More... | |
PNMWriter * | make_writer (ostream *file, bool owns_file=true, const Filename &filename=Filename(), PNMFileType *type=NULL) const |
Returns a newly-allocated PNMWriter of the suitable type for writing to the already-opened image file, or NULL if the file cannot be written for some reason. More... | |
void | operator= (const PNMImageHeader ©) |
void | output (ostream &out) const |
bool | read_header (const Filename &filename, PNMFileType *type=NULL, bool report_unknown_type=true) |
Opens up the image file and tries to read its header information to determine its size, number of channels, etc. More... | |
bool | read_header (istream &data, const string &filename=string(), PNMFileType *type=NULL, bool report_unknown_type=true) |
Reads the image header information only from the indicated stream. More... | |
void | set_comment (const string &comment) |
Writes a user comment string to the image (header). More... | |
void | set_type (PNMFileType *type) |
Sets the file type of this PNMImage. More... | |
Friends | |
class | Row |
class | Texture |
Additional Inherited Members | |
![]() | |
enum | ColorType { CT_invalid = 0, CT_grayscale = 1, CT_two_channel = 2, CT_color = 3, CT_four_channel = 4 } |
typedef pmap< PixelSpec, int > | HistMap |
typedef pvector< PixelSpec > | Palette |
typedef pvector< PixelSpecCount > | PixelCount |
![]() | |
static bool | has_alpha (ColorType color_type) |
This static variant of has_alpha() returns true if the indicated image type includes an alpha channel, false otherwise. More... | |
static bool | is_grayscale (ColorType color_type) |
This static variant of is_grayscale() returns true if the indicated image type represents a grayscale image, false otherwise. More... | |
static bool | read_magic_number (istream *file, string &magic_number, int num_bytes) |
Ensures that the first n bytes of the file are read into magic_number. More... | |
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.
A PNMImage has a color space and a maxval, the combination of which defines how a floating-point linear color value is encoded as an integer value in memory. The functions ending in _val operate on encoded colors, whereas the regular ones work with linear floating-point values. All operations are color space correct unless otherwise specified.
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.
This class is not inherently thread-safe; use it from a single thread or protect access using a mutex.
Definition at line 68 of file pnmImage.h.
|
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 336 of file pnmImage.I.
References PNMImageHeader::is_grayscale(), remove_alpha(), and set_color_type().
Referenced by alpha_fill_val(), Texture::ensure_loader_type(), ImageFile::read(), and set_num_channels().
void PNMImage::add_sub_image | ( | const PNMImage & | copy, |
int | xto, | ||
int | yto, | ||
int | xfrom = 0 , |
||
int | yfrom = 0 , |
||
int | x_size = -1 , |
||
int | y_size = -1 , |
||
float | pixel_scale = 1.0 |
||
) |
Behaves like copy_sub_image(), except the copy pixels are added to the pixels of the destination, after scaling by the specified pixel_scale.
Unlike blend_sub_image(), the alpha channel is not treated specially.
Definition at line 1218 of file pnmImage.cxx.
References get_alpha(), get_xel(), PNMImageHeader::has_alpha(), mult_sub_image(), set_alpha(), and set_xel().
Referenced by blend_sub_image().
|
inline |
Sets the entire alpha channel to the given level.
Definition at line 218 of file pnmImage.I.
References alpha_fill_val(), set_read_size(), and to_alpha_val().
Referenced by Texture::ensure_loader_type(), expand_border(), and fill_val().
void PNMImage::alpha_fill_val | ( | xelval | alpha = 0 | ) |
Sets the entire alpha channel to the given level.
Definition at line 223 of file pnmImage.cxx.
References add_alpha(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), PNMImageHeader::has_alpha(), is_valid(), read(), and set_alpha_val().
Referenced by alpha_fill(), and fill_val().
|
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 1122 of file pnmImage.I.
Referenced by apply_exponent(), gamma_correct(), gamma_correct_alpha(), and remix_channels().
|
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 1134 of file pnmImage.I.
References apply_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 1149 of file pnmImage.I.
References apply_exponent(), and PNMImage::Row::size().
void PNMImage::apply_exponent | ( | float | red_exponent, |
float | green_exponent, | ||
float | blue_exponent, | ||
float | 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 2069 of file pnmImage.cxx.
References do_fill_distance(), get_alpha(), get_gray(), PNMImageHeader::get_maxval(), get_xel(), get_xel_a(), PNMImageHeader::has_alpha(), PNMImageHeader::is_grayscale(), set_alpha(), set_gray(), set_xel(), and set_xel_a().
|
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 1060 of file pnmImage.I.
References box_filter().
Referenced by blend_sub_image(), get_bright(), and set_pixel().
void PNMImage::blend | ( | int | x, |
int | y, | ||
float | r, | ||
float | g, | ||
float | b, | ||
float | 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 1034 of file pnmImage.cxx.
References get_alpha(), get_blue(), get_green(), get_red(), get_xel(), PNMImageHeader::has_alpha(), set_alpha(), set_array(), 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 , |
||
float | 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 1178 of file pnmImage.cxx.
References add_sub_image(), blend(), copy_sub_image(), get_alpha(), get_xel(), and PNMImageHeader::has_alpha().
Referenced by copy_sub_image().
|
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 1072 of file pnmImage.I.
References box_filter_from(), and gaussian_filter().
Referenced by blend().
void PNMImage::box_filter_from | ( | float | 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 534 of file pnm-image-filter.cxx.
References gaussian_filter_from().
Referenced by box_filter().
|
inline |
A handy function to clamp values to [0..get_maxval()].
Definition at line 84 of file pnmImage.I.
References PNMImageHeader::get_maxval(), and to_val().
Referenced by operator*=(), operator+=(), operator-=(), set_color_space(), set_xel(), set_xel_a(), to_alpha_val(), 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 50 of file pnmImage.cxx.
Referenced by clear(), GeoMipTerrain::clear_color_map(), copy_from(), copy_header_from(), PNMTextMaker::get_glyph(), Texture::get_ram_image_as(), PfmVizzer::make_displacement(), read(), TextureImage::release_source_image(), PfmFile::store(), PfmFile::store_mask(), and take_from().
void PNMImage::clear | ( | int | x_size, |
int | y_size, | ||
int | num_channels = 3 , |
||
xelval | maxval = 255 , |
||
PNMFileType * | type = NULL , |
||
ColorSpace | color_space = CS_linear |
||
) |
This flavor of clear() reinitializes the image to an empty (black) image with the given dimensions.
Definition at line 78 of file pnmImage.cxx.
References clear(), copy_from(), and PNMImageHeader::has_alpha().
|
inline |
Undoes the effect of a previous call to set_read_size().
Definition at line 251 of file pnmImage.I.
References has_read_size().
Referenced by GeoMipTerrain::set_heightfield(), and set_read_size().
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 130 of file pnmImage.cxx.
References copy_header_from(), PNMImageHeader::get_x_size(), get_xel_a(), PNMImageHeader::get_y_size(), is_valid(), and set_xel_a().
Referenced by copy_from(), and rescale().
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 1785 of file pnmImage.cxx.
References get_alpha_val(), get_blue_val(), get_channel(), get_channel_val(), get_color_space(), PNMImageHeader::get_maxval(), render_spot(), 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 111 of file pnmImage.cxx.
References clear(), copy_channel(), copy_header_from(), PNMImageHeader::has_alpha(), and is_valid().
Referenced by clear(), and GeoMipTerrain::set_color_map().
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 164 of file pnmImage.cxx.
References clear(), PNMImageHeader::has_alpha(), and take_from().
Referenced by copy_channel(), copy_from(), Texture::ensure_loader_type(), 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 1119 of file pnmImage.cxx.
References blend_sub_image(), get_alpha(), get_alpha_val(), get_color_space(), 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::ensure_loader_type(), expand_border(), PNMTextGlyph::place(), and set_alpha_array().
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 , |
||
float | 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 1299 of file pnmImage.cxx.
References get_alpha(), get_alpha_val(), get_color_space(), PNMImageHeader::get_maxval(), get_xel(), get_xel_val(), PNMImageHeader::has_alpha(), lighten_sub_image(), set_alpha(), set_alpha_val(), set_xel(), and set_xel_val().
Referenced by mult_sub_image().
void PNMImage::do_fill_distance | ( | int | xi, |
int | yi, | ||
int | d | ||
) |
Recursively fills in the minimum distance measured from a certain set of points into the gray channel.
Definition at line 2257 of file pnmImage.cxx.
References get_average_xel(), get_gray_val(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), and set_gray_val().
Referenced by apply_exponent().
void PNMImage::expand_border | ( | int | left, |
int | right, | ||
int | bottom, | ||
int | top, | ||
const LColorf & | 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 1928 of file pnmImage.cxx.
References alpha_fill(), copy_sub_image(), fill(), get_color_space(), PNMImageHeader::get_maxval(), PNMImageHeader::get_num_channels(), PNMImageHeader::get_type(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), PNMImageHeader::has_alpha(), take_from(), and unfiltered_stretch_from().
Referenced by render_spot().
|
inline |
Sets the entire image (except the alpha channel) to the given color.
Definition at line 186 of file pnmImage.I.
References fill_val(), and to_val().
Referenced by DestTextureImage::copy(), Texture::ensure_loader_type(), expand_border(), fill(), and from_alpha_val().
|
inline |
Sets the entire image (except the alpha channel) to the given grayscale level.
Definition at line 197 of file pnmImage.I.
References fill(), and fill_val().
void PNMImage::fill_distance_inside | ( | const PNMImage & | mask, |
float | threshold, | ||
int | radius, | ||
bool | shrink_from_border | ||
) |
Replaces this image with a grayscale image whose gray channel represents the linear Manhattan distance from the nearest dark pixel in the given mask image, up to the specified radius value (which also becomes the new maxval).
radius may range from 0 to maxmaxval; smaller values will compute faster. A dark pixel is defined as one whose pixel value is < threshold.
If shrink_from_border is true, then the mask image is considered to be surrounded by a border of dark pixels; otherwise, the border isn't considered.
This can be used, in conjunction with threshold, to shrink a mask image inwards by a certain number of pixels.
The mask image may be the same image as this one, in which case it is destructively modified by this process.
Definition at line 1674 of file pnmImage.cxx.
References fill_distance_outside(), fill_val(), get_gray_val(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), take_from(), and to_val().
Referenced by threshold().
void PNMImage::fill_distance_outside | ( | const PNMImage & | mask, |
float | threshold, | ||
int | radius | ||
) |
Replaces this image with a grayscale image whose gray channel represents the linear Manhattan distance from the nearest white pixel in the given mask image, up to the specified radius value (which also becomes the new maxval).
radius may range from 0 to maxmaxval; smaller values will compute faster. A white pixel is defined as one whose pixel value is >= threshold.
This can be used, in conjunction with threshold, to grow a mask image outwards by a certain number of pixels.
The mask image may be the same image as this one, in which case it is destructively modified by this process.
Definition at line 1724 of file pnmImage.cxx.
References fill_val(), get_gray_val(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), rescale(), take_from(), and to_val().
Referenced by fill_distance_inside().
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 207 of file pnmImage.cxx.
References alpha_fill_val(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), is_valid(), and set_xel_val().
Referenced by fill(), fill_distance_inside(), fill_distance_outside(), fill_val(), PfmVizzer::make_displacement(), and take_from().
|
inline |
Sets the entire image (except the alpha channel) to the given grayscale level.
Definition at line 208 of file pnmImage.I.
References alpha_fill(), and fill_val().
void PNMImage::flip | ( | bool | flip_x, |
bool | flip_y, | ||
bool | transpose | ||
) |
Reverses, transposes, and/or rotates the image in-place according to the specified parameters.
If flip_x is true, the x axis is reversed; if flip_y is true, the y axis is reversed. Then, if transpose is true, the x and y axes are exchanged. These parameters can be used to select any combination of 90-degree or 180-degree rotations and flips.
Definition at line 722 of file pnmImage.cxx.
References set_maxval().
Referenced by reverse_rows().
|
inline |
A handy function to scale alpha values from [0..get_maxval()] to [0..1].
Definition at line 175 of file pnmImage.I.
References fill().
Referenced by from_val(), and get_alpha().
|
inline |
A handy function to scale non-alpha values from [0..get_maxval()] to [0..1].
Do not use this for alpha values, see from_alpha_val.
Definition at line 143 of file pnmImage.I.
References from_alpha_val().
Referenced by get_blue(), get_gray(), get_green(), get_red(), and to_alpha_val().
|
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 1097 of file pnmImage.I.
References apply_exponent(), and gamma_correct_alpha().
Referenced by gaussian_filter().
|
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 1110 of file pnmImage.I.
References apply_exponent().
Referenced by gamma_correct().
|
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 1084 of file pnmImage.I.
References gamma_correct(), and gaussian_filter_from().
Referenced by box_filter(), and GeoMipTerrain::calc_ambient_occlusion().
void PNMImage::gaussian_filter_from | ( | float | 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 548 of file pnm-image-filter.cxx.
References PfmFile::box_filter_from(), PNMImageHeader::get_num_channels(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), and PfmFile::has_no_data_value().
Referenced by box_filter_from(), and gaussian_filter().
|
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 float in the range 0..1.
Definition at line 941 of file pnmImage.I.
References from_alpha_val(), get_alpha_val(), and set_red().
Referenced by add_sub_image(), apply_exponent(), blend(), blend_sub_image(), copy_sub_image(), osxGraphicsPipe::create_cg_image(), darken_sub_image(), Texture::ensure_loader_type(), get_channel(), get_gray(), lighten_sub_image(), PfmFile::load(), mult_sub_image(), premultiply_alpha(), ImageFile::read(), threshold(), unfiltered_stretch_from(), and unpremultiply_alpha().
|
inline |
Directly access the underlying PNMImage array of alpha values.
Know what you are doing!
Definition at line 1334 of file pnmImage.I.
Referenced by get_array(), Texture::get_ram_image_as(), x11GraphicsWindow::set_properties_now(), and PfmFile::write().
|
inline |
Directly access the underlying PNMImage array of alpha values.
Know what you are doing!
Definition at line 1345 of file pnmImage.I.
References take_array().
|
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 and always linear.
Definition at line 503 of file pnmImage.I.
References set_red_val().
Referenced by copy_channel(), copy_sub_image(), darken_sub_image(), get_alpha(), get_channel_val(), get_gray_val(), get_pixel(), Texture::get_ram_image_as(), lighten_sub_image(), set_maxval(), threshold(), ImageFile::write(), and TextureImage::write_scale_info().
|
inline |
Directly access the underlying PNMImage array.
Know what you are doing!
Definition at line 1312 of file pnmImage.I.
Referenced by Texture::get_ram_image_as(), operator[](), x11GraphicsWindow::set_properties_now(), and PfmFile::write().
|
inline |
Directly access the underlying PNMImage array.
Know what you are doing!
Definition at line 1323 of file pnmImage.I.
References get_alpha_array().
float PNMImage::get_average_gray | ( | ) | const |
Returns the average grayscale component of all of the pixels in the image.
Definition at line 2330 of file pnmImage.cxx.
References get_gray(), and operator~().
Referenced by get_average_xel_a().
LRGBColorf PNMImage::get_average_xel | ( | ) | const |
Returns the average color of all of the pixels in the image.
Definition at line 2280 of file pnmImage.cxx.
References get_average_xel_a(), get_xel(), and LVecBase3f::zero().
Referenced by do_fill_distance().
LColorf 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 2305 of file pnmImage.cxx.
References get_average_gray(), get_xel_a(), and LVecBase4f::zero().
Referenced by get_average_xel().
|
inline |
Returns the blue component color at the indicated pixel.
The value returned is a linearized float in the range 0..1.
Definition at line 913 of file pnmImage.I.
References from_val(), get_blue_val(), and get_gray().
Referenced by blend(), osxGraphicsPipe::create_cg_image(), GeoMipTerrain::get_border_stitching(), get_channel(), get_green(), PNMTextGlyph::get_value(), premultiply_alpha(), remix_channels(), and unpremultiply_alpha().
|
inline |
Returns the blue component color at the indicated pixel.
The value returned is in the range 0..maxval and encoded in the configured color space.
Definition at line 474 of file pnmImage.I.
References get_gray_val(), and get_xel_val().
Referenced by copy_channel(), get_blue(), get_channel_val(), get_green_val(), Texture::get_ram_image_as(), PfmVizzer::make_displacement(), and set_maxval().
|
inline |
Returns the linear brightness of the given xel, as a linearized float 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 1020 of file pnmImage.I.
Referenced by GeoMipTerrain::get_border_stitching(), get_bright(), make_grayscale(), set_alpha(), and set_color_type().
|
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 1033 of file pnmImage.I.
References get_bright(), and get_xel().
|
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 1046 of file pnmImage.I.
References blend(), and get_xel_a().
float PNMImage::get_channel | ( | 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 a float in the range 0..1.
Definition at line 924 of file pnmImage.cxx.
References get_alpha(), get_blue(), get_green(), PNMImageHeader::get_num_channels(), get_red(), and set_channel().
Referenced by copy_channel(), and set_channel_val().
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 850 of file pnmImage.cxx.
References get_alpha_val(), get_blue_val(), get_green_val(), PNMImageHeader::get_num_channels(), get_red_val(), and set_channel_val().
Referenced by copy_channel(), Texture::ensure_loader_type(), ImageFile::read(), set_maxval(), and threshold().
|
inline |
Returns the color space in which the image is encoded.
Definition at line 296 of file pnmImage.I.
References is_valid().
Referenced by Texture::consider_rescale(), copy_channel(), copy_sub_image(), darken_sub_image(), Texture::ensure_loader_type(), expand_border(), get_read_y_size(), lighten_sub_image(), operator*=(), operator+=(), operator-=(), read(), GeoMipTerrain::set_heightfield(), and threshold().
|
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 linearized float in the range 0..1.
Definition at line 928 of file pnmImage.I.
References from_val(), get_alpha(), and get_gray_val().
Referenced by apply_exponent(), GeoMipTerrain::calc_ambient_occlusion(), osxGraphicsPipe::create_cg_image(), Texture::ensure_loader_type(), get_average_gray(), get_blue(), HeightfieldTesselator::get_elevation(), PfmFile::load(), PfmVizzer::make_displacement(), ImageFile::read(), and rescale().
|
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 and encoded in the configured color space.
Definition at line 490 of file pnmImage.I.
References get_alpha_val(), and get_xel_val().
Referenced by do_fill_distance(), fill_distance_inside(), fill_distance_outside(), get_blue_val(), get_gray(), get_pixel(), Texture::get_ram_image_as(), set_color_type(), set_maxval(), and write().
|
inline |
Returns the green component color at the indicated pixel.
The value returned is a linearized float in the range 0..1.
Definition at line 901 of file pnmImage.I.
References from_val(), get_blue(), and get_green_val().
Referenced by blend(), osxGraphicsPipe::create_cg_image(), GeoMipTerrain::get_border_stitching(), get_channel(), get_red(), premultiply_alpha(), remix_channels(), and unpremultiply_alpha().
|
inline |
Returns the green component color at the indicated pixel.
The value returned is in the range 0..maxval and encoded in the configured color space.
Definition at line 462 of file pnmImage.I.
References get_blue_val(), and get_xel_val().
Referenced by get_channel_val(), get_green(), Texture::get_ram_image_as(), get_red_val(), 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 993 of file pnmImage.cxx.
References get_alpha_val(), get_gray_val(), get_xel_val(), and set_pixel().
Referenced by set_channel().
|
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 273 of file pnmImage.I.
References get_read_y_size(), and PNMImageHeader::get_x_size().
Referenced by Texture::ensure_loader_type(), and has_read_size().
|
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 285 of file pnmImage.I.
References get_color_space(), and PNMImageHeader::get_y_size().
Referenced by Texture::ensure_loader_type(), and get_read_x_size().
|
inline |
Returns the red component color at the indicated pixel.
The value returned is a linearized float in the range 0..1.
Definition at line 889 of file pnmImage.I.
References from_val(), get_green(), and get_red_val().
Referenced by blend(), osxGraphicsPipe::create_cg_image(), GeoMipTerrain::get_border_stitching(), get_channel(), premultiply_alpha(), remix_channels(), set_xel_a(), and unpremultiply_alpha().
|
inline |
Returns the red component color at the indicated pixel.
The value returned is in the range 0..maxval and encoded in the configured color space.
Definition at line 450 of file pnmImage.I.
References get_green_val(), and get_xel_val().
Referenced by get_channel_val(), PNMTextGlyph::get_interior_flag(), Texture::get_ram_image_as(), get_red(), set_maxval(), and set_xel_val().
|
inline |
Returns the RGB color at the indicated pixel.
Each component is a linearized float in the range 0..1.
Definition at line 597 of file pnmImage.I.
References set_xel(), and LVecBase3f::zero().
Referenced by add_sub_image(), apply_exponent(), blend(), blend_sub_image(), copy_sub_image(), darken_sub_image(), get_average_xel(), get_bright(), lighten_sub_image(), PfmFile::load(), mult_sub_image(), rescale(), set_alpha_val(), set_color_space(), threshold(), and unfiltered_stretch_from().
|
inline |
Returns the RGBA color at the indicated pixel.
Each component is a linearized float in the range 0..1.
Definition at line 720 of file pnmImage.I.
References set_xel_a().
Referenced by apply_exponent(), copy_channel(), STBasicTerrain::fill_vertices(), PfmFile::gaussian_filter_from(), get_average_xel_a(), get_bright(), PfmFile::load(), operator*=(), operator+=(), operator-=(), PNMTextGlyph::place(), set_color_space(), and set_xel().
|
inline |
Returns the RGB color at the indicated pixel.
Each component is in the range 0..maxval.
Definition at line 379 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(), make_rgb(), threshold(), and TextureImage::write_scale_info().
|
inline |
Returns the RGB color at the indicated pixel.
Each component is in the range 0..maxval.
Definition at line 391 of file pnmImage.I.
References set_xel_val().
|
inline |
Returns true if set_read_size() has been called.
Definition at line 261 of file pnmImage.I.
References get_read_x_size().
Referenced by clear_read_size(), and read().
|
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 309 of file pnmImage.I.
References set_num_channels().
Referenced by alpha_fill_val(), Texture::consider_rescale(), DestTextureImage::copy(), copy_channel(), copy_from(), TexturePlacement::fill_image(), TexturePlacement::fill_swapped_image(), fill_val(), STBasicTerrain::fill_vertices(), get_color_space(), PfmFile::load(), operator*=(), operator+=(), operator-=(), write(), and TextureImage::write_scale_info().
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 , |
||
float | 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 1370 of file pnmImage.cxx.
References get_alpha(), get_alpha_val(), get_color_space(), PNMImageHeader::get_maxval(), get_xel(), get_xel_val(), PNMImageHeader::has_alpha(), set_alpha(), set_alpha_val(), set_xel(), set_xel_val(), and threshold().
Referenced by darken_sub_image().
|
inline |
Converts the image from RGB to grayscale.
Any alpha channel, if present, is left undisturbed.
Definition at line 357 of file pnmImage.I.
References make_rgb().
Referenced by GeoMipTerrain::calc_ambient_occlusion(), GeoMipTerrain::make_slope_image(), remove_alpha(), and set_color_space().
void PNMImage::make_grayscale | ( | float | rc, |
float | gc, | ||
float | 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 609 of file pnmImage.cxx.
References get_bright(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), PNMImageHeader::has_alpha(), PNMImageHeader::is_grayscale(), premultiply_alpha(), and set_gray().
void PNMImage::make_histogram | ( | PNMImage::Histogram & | histogram | ) |
Computes a histogram of the colors used in the image.
Definition at line 1977 of file pnmImage.cxx.
References perlin_noise_fill(), and PNMImageHeader::Histogram::swap().
Referenced by unfiltered_stretch_from().
|
inline |
Converts the image from grayscale to RGB.
Any alpha channel, if present, is left undisturbed.
Definition at line 368 of file pnmImage.I.
References get_xel_val(), PNMImageHeader::has_alpha(), and set_color_type().
Referenced by make_grayscale().
void PNMImage::mult_sub_image | ( | const PNMImage & | copy, |
int | xto, | ||
int | yto, | ||
int | xfrom = 0 , |
||
int | yfrom = 0 , |
||
int | x_size = -1 , |
||
int | y_size = -1 , |
||
float | pixel_scale = 1.0 |
||
) |
Behaves like copy_sub_image(), except the copy pixels are multiplied to the pixels of the destination, after scaling by the specified pixel_scale.
Unlike blend_sub_image(), the alpha channel is not treated specially.
Definition at line 1256 of file pnmImage.cxx.
References darken_sub_image(), get_alpha(), get_xel(), PNMImageHeader::has_alpha(), set_alpha(), and set_xel().
Referenced by add_sub_image().
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 1568 of file pnmImage.I.
Referenced by operator*(), and operator-().
|
inline |
Multiplies every pixel value in the image by a constant floating-point multiplier value.
Definition at line 1581 of file pnmImage.I.
References operator*().
Returns a new PNMImage in which the provided color is multiplied to each pixel in the provided image.
Definition at line 1594 of file pnmImage.I.
void PNMImage::operator*= | ( | const PNMImage & | other | ) |
Multiples each pixel in this image 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 2531 of file pnmImage.cxx.
References get_xel_a(), is_valid(), and set_xel_a().
Referenced by operator*=(), and operator-=().
void PNMImage::operator*= | ( | float | multiplier | ) |
Multiplies every pixel value in the image by a constant floating-point multiplier value.
This affects all channels.
Definition at line 2551 of file pnmImage.cxx.
References clamp_val(), get_color_space(), get_xel_a(), is_valid(), operator*=(), and set_xel_a().
void PNMImage::operator*= | ( | const LColorf & | other | ) |
Multiplies the provided color to each pixel in this image.
This is a component-wise multiplication.
Definition at line 2590 of file pnmImage.cxx.
References clamp_val(), get_color_space(), get_xel_a(), is_valid(), and set_xel_a().
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 1510 of file pnmImage.I.
Referenced by take_alpha_array().
Returns a new PNMImage in which the provided color is added to each pixel in the provided image.
Definition at line 1523 of file pnmImage.I.
References operator-().
void PNMImage::operator+= | ( | const PNMImage & | other | ) |
Sets each pixel value to the sum of the corresponding pixel values in the two given images.
Only valid when both images have the same size.
Definition at line 2388 of file pnmImage.cxx.
References clamp_val(), get_color_space(), PNMImageHeader::get_maxval(), get_xel_a(), is_valid(), and set_xel_a().
Referenced by operator~().
void PNMImage::operator+= | ( | const LColorf & | other | ) |
Adds the provided color to each pixel in this image.
Definition at line 2429 of file pnmImage.cxx.
References clamp_val(), get_color_space(), PNMImageHeader::get_maxval(), get_xel_a(), is_valid(), operator-=(), and set_xel_a().
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 1538 of file pnmImage.I.
Referenced by operator+().
Returns a new PNMImage in which the provided color is subtracted from each pixel in the provided image.
Definition at line 1551 of file pnmImage.I.
References operator*().
void PNMImage::operator-= | ( | const PNMImage & | other | ) |
Subtracts each pixel from the right image from each pixel value in this image.
Only valid when both images have the same size.
Definition at line 2475 of file pnmImage.cxx.
References clamp_val(), get_color_space(), PNMImageHeader::get_maxval(), get_xel_a(), is_valid(), and set_xel_a().
Referenced by operator+=().
void PNMImage::operator-= | ( | const LColorf & | other | ) |
Subtracts the provided color from each pixel in this image.
Definition at line 2517 of file pnmImage.cxx.
References operator*=().
|
inline |
Allows the PNMImage to appear to be a 2-d array of xels.
Definition at line 1290 of file pnmImage.I.
Referenced by PNMImage::CRow::get_alpha_val().
|
inline |
Allows the PNMImage to appear to be a 2-d array of xels.
Definition at line 1301 of file pnmImage.I.
References get_array().
PNMImage PNMImage::operator~ | ( | ) | const |
Returns a new PNMImage that is the complement of this PNMImage.
This operation is not color-space correct.
Definition at line 2355 of file pnmImage.cxx.
References operator+=().
Referenced by get_average_gray().
void PNMImage::perlin_noise_fill | ( | float | sx, |
float | 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 2008 of file pnmImage.cxx.
References PerlinNoise2::noise(), and set_xel().
Referenced by make_histogram().
void PNMImage::perlin_noise_fill | ( | StackedPerlinNoise2 & | perlin | ) |
Variant of perlin_noise_fill that uses an existing StackedPerlinNoise2 object.
Definition at line 2027 of file pnmImage.cxx.
References StackedPerlinNoise2::noise(), remix_channels(), and set_xel().
void PNMImage::premultiply_alpha | ( | ) |
Converts an image in-place to its "premultiplied" form, where, for every pixel in the image, the red, green, and blue components are multiplied by that pixel's alpha value.
This does not modify any alpha values.
Definition at line 636 of file pnmImage.cxx.
References get_alpha(), get_blue(), get_green(), get_red(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), PNMImageHeader::has_alpha(), set_xel(), and unpremultiply_alpha().
Referenced by make_grayscale().
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 772 of file pnm-image-filter.cxx.
References Thread::consider_yield(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), and set_xel_a().
Referenced by Texture::consider_rescale(), DestTextureImage::copy(), Texture::ensure_loader_type(), TexturePlacement::fill_image(), TexturePlacement::fill_swapped_image(), PfmFile::gaussian_filter_from(), Texture::generate_simple_ram_image(), and read().
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 245 of file pnmImage.cxx.
References clear(), and PNMImageHeader::make_reader().
Referenced by alpha_fill_val(), AssimpLoader::build_graph(), osxGraphicsStateGuardian::draw_resize_box(), Texture::ensure_loader_type(), WindowFramework::load_default_model(), EggReader::pre_process_egg_file(), PfmFile::read(), ImageFile::read(), read(), GeoMipTerrain::set_color_map(), GeoMipTerrain::set_heightfield(), HeightfieldTesselator::set_heightfield(), and x11GraphicsWindow::set_properties_now().
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 270 of file pnmImage.cxx.
References clear(), PNMImageHeader::make_reader(), 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 295 of file pnmImage.cxx.
References clear(), copy_header_from(), get_color_space(), PNMImageHeader::get_maxval(), PNMImageHeader::get_num_channels(), PNMImageHeader::get_type(), has_read_size(), PNMReader::is_floating_point(), PNMReader::is_valid(), PNMReader::prepare_read(), quick_filter_from(), PNMReader::read_data(), PNMReader::read_pfm(), PNMReader::set_read_size(), PfmFile::store(), take_from(), and write().
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 2046 of file pnmImage.cxx.
References apply_exponent(), get_blue(), get_green(), PNMImageHeader::get_num_channels(), get_red(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), set_xel(), and LMatrix4f::xform_point().
Referenced by perlin_noise_fill().
|
inline |
Removes the image's alpha channel, if it exists.
Definition at line 346 of file pnmImage.I.
References PNMImageHeader::is_grayscale(), make_grayscale(), and set_color_type().
Referenced by add_alpha(), and ImageFile::write().
void PNMImage::render_spot | ( | const LColorf & | fg, |
const LColorf & | bg, | ||
float | min_radius, | ||
float | 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 1846 of file pnmImage.cxx.
References expand_border(), and set_xel_a().
Referenced by copy_channel(), and Spotlight::get_vector_to_light().
void PNMImage::rescale | ( | float | min_val, |
float | max_val | ||
) |
Rescales the RGB channel values so that any values in the original image between min_val and max_val are expanded to the range 0 .
. 1. Values below min_val are set to 0, and values above max_val are set to 1. Does not affect the alpha channel, if any.
Definition at line 1752 of file pnmImage.cxx.
References copy_channel(), get_gray(), PNMImageHeader::get_x_size(), get_xel(), PNMImageHeader::get_y_size(), set_gray(), and set_xel().
Referenced by fill_distance_outside().
void PNMImage::reverse_rows | ( | ) |
Performs an in-place reversal of the row (y) data.
Definition at line 688 of file pnmImage.cxx.
References flip().
Referenced by unpremultiply_alpha().
|
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 1007 of file pnmImage.I.
References get_bright(), set_alpha_val(), and to_alpha_val().
Referenced by add_sub_image(), apply_exponent(), blend(), copy_sub_image(), darken_sub_image(), Texture::ensure_loader_type(), TexturePlacement::fill_image(), TexturePlacement::fill_swapped_image(), Texture::get_ram_image_as(), lighten_sub_image(), mult_sub_image(), ImageFile::read(), set_channel(), set_gray(), PfmFile::store(), threshold(), and unfiltered_stretch_from().
void PNMImage::set_alpha_array | ( | xelval * | alpha | ) |
Replaces the underlying PNMImage alpha array with the indicated pointer.
Know what you are doing! The new array must be the correct size and must have been allocated via PANDA_MALLOC_ARRAY(). The PNMImage object becomes the owner of this pointer and will eventually free it with PANDA_FREE_ARRAY(). The previous array, if any, will be freed with PANDA_FREE_ARRAY() when this call is made.
Definition at line 1100 of file pnmImage.cxx.
References copy_sub_image().
Referenced by set_array().
|
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.
This value is always linearly encoded, even if the image is set to the sRGB color space.
Definition at line 585 of file pnmImage.I.
References get_xel().
Referenced by alpha_fill_val(), copy_channel(), copy_sub_image(), darken_sub_image(), TexturePlacement::flag_error_image(), lighten_sub_image(), set_alpha(), set_channel_val(), set_gray_val(), set_maxval(), set_pixel(), and threshold().
void PNMImage::set_array | ( | xel * | array | ) |
Replaces the underlying PNMImage array with the indicated pointer.
Know what you are doing! The new array must be the correct size and must have been allocated via PANDA_MALLOC_ARRAY(). The PNMImage object becomes the owner of this pointer and will eventually free it with PANDA_FREE_ARRAY(). The previous array, if any, will be freed with PANDA_FREE_ARRAY() when this call is made.
Definition at line 1080 of file pnmImage.cxx.
References set_alpha_array().
Referenced by blend().
|
inline |
Sets the blue component color only at the indicated pixel.
The value given should be a linearized float in the range 0..1.
Definition at line 977 of file pnmImage.I.
References set_blue_val(), set_gray(), and to_val().
Referenced by Texture::get_ram_image_as(), set_channel(), and set_green().
|
inline |
Sets the blue component color only at the indicated pixel.
The value given should be in the range 0..maxval, encoded in the configured color space. See set_blue if you instead have a linearized and normalized floating-point value.
Definition at line 548 of file pnmImage.I.
References set_gray_val().
Referenced by copy_channel(), PfmVizzer::make_displacement(), set_blue(), set_channel_val(), set_green_val(), and set_maxval().
void PNMImage::set_channel | ( | int | x, |
int | y, | ||
int | channel, | ||
float | 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 a float in the range 0..1.
Definition at line 959 of file pnmImage.cxx.
References get_pixel(), set_alpha(), set_blue(), set_green(), and set_red().
Referenced by copy_channel(), and get_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 885 of file pnmImage.cxx.
References get_channel(), set_alpha_val(), set_blue_val(), set_green_val(), and set_red_val().
Referenced by copy_channel(), and get_channel_val().
void PNMImage::set_color_space | ( | ColorSpace | color_space | ) |
Converts the colors in the image to the indicated color space.
This may be a lossy operation, in particular when going from sRGB to linear. The alpha channel remains untouched.
Note that, because functions like get_xel() and set_xel() work on linearized floating-point values, this conversion won't affect those values (aside from some minor discrepancies due to storage precision). It does affect the values used by get_xel_val() and set_xel_val(), though, since those operate on encoded colors.
Some color spaces, particularly scRGB, may enforce the use of a particular maxval setting.
Definition at line 524 of file pnmImage.cxx.
References clamp_val(), get_xel(), get_xel_a(), and make_grayscale().
Referenced by set_color_type().
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 463 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_color_space(), set_gray(), and set_xel_val().
Referenced by add_alpha(), make_rgb(), remove_alpha(), set_num_channels(), and write().
|
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 linearized float in the range 0..1.
Definition at line 994 of file pnmImage.I.
References set_alpha(), set_gray_val(), and to_val().
Referenced by apply_exponent(), Texture::get_ram_image_as(), make_grayscale(), rescale(), set_blue(), set_color_type(), PfmFile::store(), and PfmFile::store_mask().
|
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, encoded in the configured color space. See set_gray if you instead have a linearized normalized floating-point value.
Definition at line 568 of file pnmImage.I.
References set_alpha_val().
Referenced by do_fill_distance(), set_blue_val(), set_gray(), set_maxval(), and ImageFile::write().
|
inline |
Sets the green component color only at the indicated pixel.
The value given should be a linearized float in the range 0..1.
Definition at line 965 of file pnmImage.I.
References set_blue(), set_green_val(), and to_val().
Referenced by Texture::get_ram_image_as(), set_channel(), and set_red().
|
inline |
Sets the green component color only at the indicated pixel.
The value given should be in the range 0..maxval, encoded in the configured color space. See set_green if you instead have a linearized and normalized floating-point value.
Definition at line 533 of file pnmImage.I.
References set_blue_val().
Referenced by set_channel_val(), set_green(), set_maxval(), and set_red_val().
void PNMImage::set_maxval | ( | xelval | maxval | ) |
Rescales the image to the indicated maxval.
Definition at line 803 of file pnmImage.cxx.
References get_alpha_val(), get_blue_val(), get_channel_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(), flip(), and x11GraphicsWindow::set_properties_now().
|
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 323 of file pnmImage.I.
References add_alpha(), and set_color_type().
Referenced by Texture::get_ram_image_as(), and is_valid().
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 1015 of file pnmImage.cxx.
References blend(), set_alpha_val(), and set_xel_val().
Referenced by get_pixel().
|
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 238 of file pnmImage.I.
References clear_read_size().
Referenced by alpha_fill(), Texture::consider_rescale(), Texture::ensure_loader_type(), and GeoMipTerrain::set_heightfield().
|
inline |
Sets the red component color only at the indicated pixel.
The value given should be a linearized float in the range 0..1.
Definition at line 953 of file pnmImage.I.
References set_green(), set_red_val(), and to_val().
Referenced by get_alpha(), Texture::get_ram_image_as(), and set_channel().
|
inline |
Sets the red component color only at the indicated pixel.
The value given should be in the range 0..maxval, encoded in the configured color space. See set_red if you instead have a linearized and normalized floating-point value.
Definition at line 518 of file pnmImage.I.
References set_green_val().
Referenced by get_alpha_val(), set_channel_val(), set_maxval(), and set_red().
|
inline |
Changes the RGB color at the indicated pixel.
Each component is a linearized float in the range 0..1.
Definition at line 641 of file pnmImage.I.
References clamp_val(), and PNMImageHeader::get_maxval().
Referenced by add_sub_image(), apply_exponent(), blend(), GeoMipTerrain::calc_ambient_occlusion(), copy_sub_image(), darken_sub_image(), TexturePlacement::fill_image(), TexturePlacement::fill_swapped_image(), get_xel(), lighten_sub_image(), GeoMipTerrain::make_slope_image(), mult_sub_image(), perlin_noise_fill(), premultiply_alpha(), remix_channels(), rescale(), set_xel(), PfmFile::store(), threshold(), unfiltered_stretch_from(), and unpremultiply_alpha().
|
inline |
Changes the RGB color at the indicated pixel.
Each component is a linearized float in the range 0..1.
Definition at line 696 of file pnmImage.I.
References set_xel().
|
inline |
Changes all three color components at the indicated pixel to the same value.
The value is a linearized float in the range 0..1.
Definition at line 708 of file pnmImage.I.
References get_xel_a(), set_xel_val(), and to_val().
|
inline |
Changes the RGBA color at the indicated pixel.
Each component is a linearized float in the range 0..1.
Definition at line 789 of file pnmImage.I.
References clamp_val(), and PNMImageHeader::get_maxval().
Referenced by apply_exponent(), copy_channel(), get_xel_a(), operator*=(), operator+=(), operator-=(), PNMTextGlyph::place(), quick_filter_from(), render_spot(), set_xel_a(), and PfmFile::store().
|
inline |
Changes the RGBA color at the indicated pixel.
Each component is a linearized float in the range 0..1.
Definition at line 877 of file pnmImage.I.
References get_red(), and set_xel_a().
|
inline |
Changes the RGB color at the indicated pixel.
Each component is in the range 0..maxval, encoded in the configured color space. See set_xel if you instead have a linearized and normalized floating-point value.
Definition at line 406 of file pnmImage.I.
Referenced by copy_sub_image(), darken_sub_image(), fill_val(), TexturePlacement::flag_error_image(), get_xel_val(), lighten_sub_image(), PfmVizzer::make_displacement(), set_color_type(), set_pixel(), set_xel(), set_xel_val(), and threshold().
|
inline |
Changes the RGB color at the indicated pixel.
Each component is in the range 0..maxval, encoded in the configured color space. See set_xel if you instead have a linearized and normalized floating-point value.
Definition at line 421 of file pnmImage.I.
References set_xel_val().
|
inline |
Changes all three color components at the indicated pixel to the same value.
The value is in the range component is in the range 0..maxval, encoded in the configured color space. See set_xel if you instead have a linearized and normalized floating-point value.
Definition at line 437 of file pnmImage.I.
References get_red_val().
|
inline |
Returns the underlying PNMImage array and removes it from the PNMImage.
You become the owner of this array and must eventually free it with PANDA_FREE_ARRAY() (or pass it to another PNMImage with set_alpha_array()). Know what you are doing!
Definition at line 1375 of file pnmImage.I.
References PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), and operator+().
Referenced by take_array().
|
inline |
Returns the underlying PNMImage array and removes it from the PNMImage.
You become the owner of this array and must eventually free it with PANDA_FREE_ARRAY() (or pass it to another PNMImage with set_array()). Know what you are doing!
Definition at line 1359 of file pnmImage.I.
References take_alpha_array().
Referenced by get_alpha_array().
void PNMImage::take_from | ( | PNMImage & | orig | ) |
Move the contents of the other image into this one, and empty the other image.
Definition at line 184 of file pnmImage.cxx.
References clear(), fill_val(), and PNMImageHeader::has_alpha().
Referenced by Texture::consider_rescale(), copy_header_from(), Texture::ensure_loader_type(), expand_border(), fill_distance_inside(), fill_distance_outside(), and read().
void PNMImage::threshold | ( | const PNMImage & | select_image, |
int | channel, | ||
float | 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, channel). 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. As a special case, lt and ge may both be 1x1 images instead of the source image size.
Definition at line 1451 of file pnmImage.cxx.
References fill_distance_inside(), get_alpha(), get_alpha_val(), get_channel_val(), get_color_space(), 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(), set_xel_val(), and to_val().
Referenced by lighten_sub_image().
|
inline |
A handy function to scale alpha values from [0..1] to [0..get_maxval()].
Definition at line 131 of file pnmImage.I.
References clamp_val(), from_val(), and PNMImageHeader::get_maxval().
Referenced by alpha_fill(), set_alpha(), and to_val().
|
inline |
A handy function to scale non-alpha values from [0..1] to [0..get_maxval()].
Do not use this for alpha values, see to_alpha_val.
Definition at line 96 of file pnmImage.I.
References clamp_val(), PNMImageHeader::get_maxval(), and to_alpha_val().
Referenced by clamp_val(), fill(), fill_distance_inside(), fill_distance_outside(), set_blue(), set_gray(), set_green(), set_red(), set_xel(), and threshold().
void PNMImage::unfiltered_stretch_from | ( | const PNMImage & | copy | ) |
Resizes from the indicated image into this one by performing a nearest-point sample.
Definition at line 1950 of file pnmImage.cxx.
References get_alpha(), PNMImageHeader::get_x_size(), get_xel(), PNMImageHeader::get_y_size(), PNMImageHeader::has_alpha(), make_histogram(), set_alpha(), and set_xel().
Referenced by expand_border().
void PNMImage::unpremultiply_alpha | ( | ) |
Converts an image in-place to its "straight alpha" form (presumably from a "premultiplied" form), where, for every pixel in the image, the red, green, and blue components are divided by that pixel's alpha value.
This does not modify any alpha values.
Definition at line 664 of file pnmImage.cxx.
References get_alpha(), get_blue(), get_green(), get_red(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), PNMImageHeader::has_alpha(), reverse_rows(), and set_xel().
Referenced by premultiply_alpha().
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 362 of file pnmImage.cxx.
References is_valid(), and PNMImageHeader::make_writer().
Referenced by Texture::ensure_loader_type(), EggReader::pre_process_egg_file(), read(), DisplayRegion::save_screenshot(), ImageFile::write(), write(), and ImageWriter::write_image().
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 387 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 412 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(), PfmFile::load(), set_color_type(), PNMWriter::supports_grayscale(), PNMWriter::supports_integer(), PNMWriter::write_data(), and PNMWriter::write_pfm().