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 Types | |
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 |
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 | blend (int x, int y, const RGBColord &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 Colord &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 | 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. | |
RGBColord | get_average_xel () const |
Returns the average color of all of the pixels in the image. | |
Colord | 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. | |
ColorType | get_color_type () const |
Returns the image type of the image, as an enumerated value. | |
string | get_comment () const |
Gets the user comment from the file. | |
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. | |
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. | |
int | get_num_channels () const |
Returns the number of channels in the image. | |
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. | |
PNMFileType * | get_type () const |
If the file type is known (e.g. | |
int | get_x_size () const |
Returns the number of pixels in the X direction. | |
RGBColord | get_xel (int x, int y) const |
Returns the RGB color at the indicated pixel. | |
Colord | 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. | |
int | get_y_size () const |
Returns the number of pixels in the Y direction. | |
bool | has_alpha () const |
Returns true if the image includes an alpha channel, false otherwise. | |
bool | has_read_size () const |
Returns true if set_read_size() has been called. | |
bool | has_type () const |
Returns true if the PNMImageHeader knows what type it is, false otherwise. | |
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. | |
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. | |
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. | |
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. | |
void | make_rgb () |
Converts the image from grayscale to RGB. | |
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. | |
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. | |
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. | |
PNMImage | operator* (double multiplier) const |
Multiplies every pixel value in the image by a constant floating-point multiplier value. | |
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 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. | |
PNMImage | operator+ (const Colord &other) const |
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. | |
void | operator+= (const Colord &other) |
Returns a new PNMImage in which the provided color is added to each pixel in the provided image. | |
PNMImage | operator- (const Colord &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 Colord &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 | output (ostream &out) const |
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 (const Filename &filename, PNMFileType *type=NULL, bool report_unknown_type=true) |
Reads the indicated image filename. | |
bool | read (PNMReader *reader) |
This flavor of read() uses an already-existing PNMReader to read the image file. | |
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_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. | |
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. | |
void | remix_channels (const LMatrix4f &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 Colord &fg, const Colord &bg, double min_radius, double max_radius) |
Renders a solid-color circle, with a fuzzy edge, into the center of the PNMImage. | |
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_comment (const string &comment) |
Writes a user comment string to the image (header). | |
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_type (PNMFileType *type) |
Sets the file type of this PNMImage. | |
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 (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, const RGBColord &value) |
Changes the RGB color at the indicated pixel. | |
void | set_xel_a (int x, int y, const Colord &value) |
Changes the RGBA color at the indicated pixel. | |
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_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 | set_xel_val (int x, int y, const xel &value) |
Changes the RGB color at the indicated pixel. | |
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 (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. | |
bool | write (PNMWriter *writer) const |
This flavor of write() uses an already-existing PNMWriter to write the image file. | |
Static Public Member Functions | |
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. | |
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. | |
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. | |
Protected Member Functions | |
bool | compute_histogram (HistMap &hist, xel *array, xelval *alpha, int max_colors=0) |
Computes a histogram of the colors used in the indicated rgb/grayscale array and/or alpha array. | |
bool | compute_palette (Palette &palette, xel *array, xelval *alpha, int max_colors=0) |
Returns a linear list of all of the colors in the image, similar to compute_histogram(). | |
void | record_color (HistMap &hist, const PixelSpec &color) |
Records the indicated color in the histogram. | |
Protected Attributes | |
string | _comment |
xelval | _maxval |
int | _num_channels |
PNMFileType * | _type |
int | _x_size |
int | _y_size |
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::blend | ( | int | x, |
int | y, | ||
const RGBColord & | 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 669 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 772 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().
bool PNMImageHeader::compute_histogram | ( | PNMImageHeader::HistMap & | hist, |
xel * | array, | ||
xelval * | alpha, | ||
int | max_colors = 0 |
||
) | [protected, inherited] |
Computes a histogram of the colors used in the indicated rgb/grayscale array and/or alpha array.
This is most likely to be useful in a PNMWriter class, but it is defined at this level in case it has general utilty for PNMImages.
Also see PNMImage::make_histogram(), which is a higher-level function.
The max_colors parameter, if greater than zero, limits the maximum number of colors we are interested in. If we encounter more than this number of colors, the function aborts before completion and returns false; otherwise, it returns true.
Definition at line 450 of file pnmImageHeader.cxx.
References PNMImageHeader::get_color_type(), and PNMImageHeader::record_color().
Referenced by PNMImageHeader::compute_palette(), and make_histogram().
bool PNMImageHeader::compute_palette | ( | PNMImageHeader::Palette & | palette, |
xel * | array, | ||
xelval * | alpha, | ||
int | max_colors = 0 |
||
) | [protected, inherited] |
Returns a linear list of all of the colors in the image, similar to compute_histogram().
Definition at line 506 of file pnmImageHeader.cxx.
References PNMImageHeader::compute_histogram().
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 1075 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 714 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(), 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 817 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 Colord & | 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 1217 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::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().
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 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 1375 of file pnmImage.cxx.
References get_gray().
RGBColord PNMImage::get_average_xel | ( | ) | const |
Returns the average color of all of the pixels in the image.
Definition at line 1327 of file pnmImage.cxx.
References get_xel(), and LVecBase3d::zero().
Colord 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 1351 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 | ||
) | 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_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_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 559 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().
PNMImageHeader::ColorType PNMImageHeader::get_color_type | ( | ) | const [inline, inherited] |
Returns the image type of the image, as an enumerated value.
This is really just the number of channels cast to the enumerated type.
Definition at line 76 of file pnmImageHeader.I.
Referenced by PNMImageHeader::compute_histogram(), osxGraphicsPipe::create_cg_image(), PNMImageHeader::has_alpha(), PNMImageHeader::is_grayscale(), and set_color_type().
string PNMImageHeader::get_comment | ( | ) | const [inline, inherited] |
Gets the user comment from the file.
Definition at line 186 of file pnmImageHeader.I.
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 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(), and set_maxval().
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().
xelval PNMImageHeader::get_maxval | ( | ) | const [inline, inherited] |
Returns the maximum channel value allowable for any pixel in this image; for instance, 255 for a typical 8-bit-per-channel image.
A pixel with this value is full on.
Definition at line 152 of file pnmImageHeader.I.
Referenced by clamp_val(), DestTextureImage::copy(), copy_channel(), copy_sub_image(), darken_sub_image(), Texture::do_load_one(), Texture::do_read_one(), expand_border(), TexturePlacement::fill_image(), TexturePlacement::fill_swapped_image(), from_val(), lighten_sub_image(), operator+=(), read(), threshold(), to_val(), and ImageFile::write().
int PNMImageHeader::get_num_channels | ( | ) | const [inline, inherited] |
Returns the number of channels in the image.
Definition at line 87 of file pnmImageHeader.I.
Referenced by osxGraphicsPipe::create_cg_image(), Texture::do_load_one(), Texture::do_read_one(), expand_border(), TexturePlacement::fill_image(), TexturePlacement::fill_swapped_image(), Texture::generate_simple_ram_image(), get_channel_val(), ImageFile::read(), read(), remix_channels(), SourceTextureImage::set_header(), and threshold().
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 628 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().
PNMFileType * PNMImageHeader::get_type | ( | ) | const [inline, inherited] |
If the file type is known (e.g.
has_type() returns true), returns its PNMFileType pointer; otherwise, returns NULL.
Reimplemented in PNMReader, and PNMWriter.
Definition at line 219 of file pnmImageHeader.I.
Referenced by Texture::do_load_one(), Texture::do_read_one(), expand_border(), and read().
int PNMImageHeader::get_x_size | ( | ) | const [inline, inherited] |
Returns the number of pixels in the X direction.
This is one more than the largest allowable X coordinate.
Definition at line 164 of file pnmImageHeader.I.
Referenced by alpha_fill_val(), Texture::consider_rescale(), copy_channel(), osxGraphicsPipe::create_cg_image(), Texture::do_load_one(), Texture::do_read_one(), expand_border(), fill_val(), HeightfieldTesselator::generate(), HeightfieldTesselator::get_elevation(), get_read_x_size(), PNMTextGlyph::get_right(), PNMTextGlyph::get_width(), make_grayscale(), PNMTextGlyph::place(), ImageTransformColors::process_image(), quick_filter_from(), ImageFile::read(), remix_channels(), set_color_type(), SourceTextureImage::set_header(), GeoMipTerrain::set_heightfield(), set_maxval(), threshold(), and ImageFile::write().
RGBColord 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 blend(), blend_sub_image(), copy_sub_image(), darken_sub_image(), get_average_xel(), lighten_sub_image(), PNMTextGlyph::place(), ImageTransformColors::process_image(), and threshold().
Colord 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 copy_channel(), and get_average_xel_a().
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().
int PNMImageHeader::get_y_size | ( | ) | const [inline, inherited] |
Returns the number of pixels in the Y direction.
This is one more than the largest allowable Y coordinate.
Definition at line 176 of file pnmImageHeader.I.
Referenced by alpha_fill_val(), Texture::consider_rescale(), copy_channel(), osxGraphicsPipe::create_cg_image(), Texture::do_load_one(), Texture::do_read_one(), expand_border(), fill_val(), HeightfieldTesselator::generate(), PNMTextGlyph::get_bottom(), HeightfieldTesselator::get_elevation(), PNMTextGlyph::get_height(), get_read_y_size(), make_grayscale(), PNMTextGlyph::place(), ImageTransformColors::process_image(), quick_filter_from(), ImageFile::read(), remix_channels(), set_color_type(), SourceTextureImage::set_header(), GeoMipTerrain::set_heightfield(), set_maxval(), threshold(), and ImageFile::write().
bool PNMImageHeader::has_alpha | ( | PNMImageHeader::ColorType | color_type | ) | [inline, static, inherited] |
This static variant of has_alpha() returns true if the indicated image type includes an alpha channel, false otherwise.
Definition at line 126 of file pnmImageHeader.I.
Referenced by blend_sub_image(), copy_sub_image(), darken_sub_image(), Texture::do_read_one(), TexturePlacement::fill_image(), TexturePlacement::fill_swapped_image(), TexturePlacement::flag_error_image(), lighten_sub_image(), PNMTextGlyph::place(), threshold(), and ImageFile::write().
bool PNMImageHeader::has_alpha | ( | ) | const [inline, inherited] |
Returns true if the image includes an alpha channel, false otherwise.
Unlike is_grayscale(), if this returns false it is an error to call any of the functions accessing the alpha channel.
Definition at line 139 of file pnmImageHeader.I.
References PNMImageHeader::get_color_type().
Referenced by alpha_fill_val(), blend(), clear(), copy_from(), copy_header_from(), copy_sub_image(), darken_sub_image(), expand_border(), get_xel_a(), lighten_sub_image(), make_grayscale(), make_rgb(), quick_filter_from(), PNMReader::read_data(), set_color_type(), set_maxval(), set_xel_a(), take_from(), 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 PNMImageHeader::has_type | ( | ) | const [inline, inherited] |
Returns true if the PNMImageHeader knows what type it is, false otherwise.
Definition at line 207 of file pnmImageHeader.I.
bool PNMImageHeader::is_grayscale | ( | PNMImageHeader::ColorType | color_type | ) | [inline, static, inherited] |
This static variant of is_grayscale() returns true if the indicated image type represents a grayscale image, false otherwise.
Definition at line 100 of file pnmImageHeader.I.
bool PNMImageHeader::is_grayscale | ( | ) | const [inline, inherited] |
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.
(The gray color is actually stored in the blue channel, and the red and green channels are ignored.)
Definition at line 114 of file pnmImageHeader.I.
References PNMImageHeader::get_color_type().
Referenced by add_alpha(), make_grayscale(), remove_alpha(), set_color_type(), and set_maxval().
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(), 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 887 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 | ( | 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 492 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_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::make_slope_image().
void PNMImage::make_histogram | ( | PNMImage::Histogram & | histogram | ) |
Computes a histogram of the colors used in the image.
Definition at line 1238 of file pnmImage.cxx.
References PNMImageHeader::compute_histogram(), and PNMImageHeader::Histogram::swap().
PNMReader * PNMImageHeader::make_reader | ( | const Filename & | filename, |
PNMFileType * | type = NULL , |
||
bool | report_unknown_type = true |
||
) | const [inherited] |
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.
The filename "-" always stands for standard input. If type is specified, it is a suggestion for the file type to use.
The PNMReader should be deleted when it is no longer needed.
Definition at line 89 of file pnmImageHeader.cxx.
References VirtualFileSystem::get_global_ptr(), and VirtualFileSystem::open_read_file().
Referenced by read(), and PNMImageHeader::read_header().
PNMReader * PNMImageHeader::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 [inherited] |
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.
owns_file should be set true if the PNMReader is to be considered the owner of the stream pointer (in which case the stream will be deleted on completion, whether successful or not), or false if it should not delete it.
The filename parameter is optional here, since the file has already been opened; it is only used to examine the extension and attempt to guess the file type.
If magic_number is nonempty, it is assumed to represent the first few bytes that have already been read from the file. Some file types may have difficulty if this is more than two bytes.
If type is non-NULL, it is a suggestion for the file type to use.
The PNMReader should be deleted when it is no longer needed.
Definition at line 155 of file pnmImageHeader.cxx.
References VirtualFileSystem::close_read_file(), PNMFileTypeRegistry::get_global_ptr(), VirtualFileSystem::get_global_ptr(), PNMFileTypeRegistry::get_type_from_extension(), PNMReader::is_valid(), PNMFileType::make_reader(), and PNMImageHeader::read_magic_number().
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().
PNMWriter * PNMImageHeader::make_writer | ( | const Filename & | filename, |
PNMFileType * | type = NULL |
||
) | const [inherited] |
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.
The filename "-" always stands for standard output. If type is specified, it is a suggestion for the file type to use.
The PNMWriter should be deleted when it is no longer needed.
Definition at line 270 of file pnmImageHeader.cxx.
References Filename::get_extension(), and Filename::open_write().
Referenced by write().
PNMWriter * PNMImageHeader::make_writer | ( | ostream * | file, |
bool | owns_file = true , |
||
const Filename & | filename = Filename() , |
||
PNMFileType * | type = NULL |
||
) | const [inherited] |
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.
owns_file should be set true if the PNMWriter is to be considered the owner of the stream pointer (in which case the stream will be deleted on completion, whether successful or not), or false if it should not delete it.
The filename parameter is optional here, since the file has already been opened; it is only used to examine the extension and attempt to guess the intended file type.
If type is non-NULL, it is a suggestion for the file type to use.
The PNMWriter should be deleted when it is no longer needed.
Definition at line 343 of file pnmImageHeader.cxx.
References PNMFileTypeRegistry::get_global_ptr(), PNMFileTypeRegistry::get_type_from_extension(), PNMWriter::is_valid(), and PNMFileType::make_writer().
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 1025 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 1038 of file pnmImage.I.
void PNMImage::operator*= | ( | double | multiplier | ) |
Multiplies every pixel value in the image by a constant floating-point multiplier value.
Definition at line 1580 of file pnmImage.cxx.
References clamp_val().
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 1549 of file pnmImage.cxx.
References from_val(), and to_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 967 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 980 of file pnmImage.I.
void PNMImage::operator+= | ( | const Colord & | other | ) |
Returns a new PNMImage in which the provided color is added to each pixel in the provided image.
Definition at line 1465 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 1433 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 1008 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 995 of file pnmImage.I.
void PNMImage::operator-= | ( | const Colord & | other | ) |
Returns a new PNMImage in which the provided color is subtracted from each pixel in the provided image.
Definition at line 1534 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 1502 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 1399 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 1269 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 1288 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 succesful or not.
Definition at line 307 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 257 of file pnmImage.cxx.
References clear(), and PNMImageHeader::make_reader().
Referenced by Texture::do_read_one(), osxGraphicsStateGuardian::draw_resize_box(), ImageReader::handle_args(), WindowFramework::load_default_model(), 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 282 of file pnmImage.cxx.
References clear(), PNMImageHeader::make_reader(), and read().
bool PNMImageHeader::read_header | ( | const Filename & | filename, |
PNMFileType * | type = NULL , |
||
bool | report_unknown_type = true |
||
) | [inherited] |
Opens up the image file and tries to read its header information to determine its size, number of channels, etc.
If successful, updates the header information and returns true; otherwise, returns false.
Definition at line 34 of file pnmImageHeader.cxx.
References PNMImageHeader::make_reader().
Referenced by Texture::do_read_one(), SourceTextureImage::read_header(), and GeoMipTerrain::set_heightfield().
bool PNMImageHeader::read_header | ( | istream & | data, |
const string & | filename = string() , |
||
PNMFileType * | type = NULL , |
||
bool | report_unknown_type = true |
||
) | [inherited] |
Reads the image header information only 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 62 of file pnmImageHeader.cxx.
References PNMImageHeader::make_reader().
bool PNMImageHeader::read_magic_number | ( | istream * | file, |
string & | magic_number, | ||
int | num_bytes | ||
) | [static, inherited] |
Ensures that the first n bytes of the file are read into magic_number.
If magic_number is initially nonempty, assumes these represent the first few bytes already extracted. Returns true if successful, false if an end of file or error occurred before num_bytes could be read.
Definition at line 408 of file pnmImageHeader.cxx.
Referenced by PNMImageHeader::make_reader().
void PNMImageHeader::record_color | ( | PNMImageHeader::HistMap & | hist, |
const PixelSpec & | color | ||
) | [inline, protected, inherited] |
Records the indicated color in the histogram.
Definition at line 244 of file pnmImageHeader.I.
Referenced by PNMImageHeader::compute_histogram().
void PNMImage::remix_channels | ( | const LMatrix4f & | 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 237 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 Colord & | fg, |
const Colord & | 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 1135 of file pnmImage.cxx.
References set_xel_a().
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 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 594 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 442 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 PNMImageHeader::set_comment | ( | const string & | comment | ) | [inline, inherited] |
Writes a user comment string to the image (header).
Definition at line 196 of file pnmImageHeader.I.
Referenced by DisplayRegion::save_screenshot().
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 make_grayscale(), GeoMipTerrain::make_slope_image(), 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 513 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().
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 accomodate; 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 650 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 PNMImageHeader::set_type | ( | PNMFileType * | type | ) | [inline, inherited] |
Sets the file type of this PNMImage.
This will be the default type used when an image is read, if the type cannot be determined by magic number or inferred by extension, or the type used when the image is written, if the type cannot be inferred from the filename extension.
Definition at line 234 of file pnmImageHeader.I.
Referenced by ImageFile::read().
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 | ( | 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, | ||
const RGBColord & | 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 blend(), copy_sub_image(), darken_sub_image(), TexturePlacement::fill_image(), TexturePlacement::fill_swapped_image(), lighten_sub_image(), perlin_noise_fill(), PNMTextGlyph::place(), ImageTransformColors::process_image(), remix_channels(), and threshold().
void PNMImage::set_xel_a | ( | int | x, |
int | y, | ||
const Colord & | 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 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 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 966 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 | ( | 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 succesful or not.
Definition at line 412 of file pnmImage.cxx.
References PNMWriter::copy_header_from(), is_valid(), 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 362 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().
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().