#include <pnmImage.h>
Inheritance diagram for PNMImage:
Public Types | |
enum | ColorType { CT_invalid = 0, CT_grayscale = 1, CT_two_channel = 2, CT_color = 3, CT_four_channel = 4 } |
Public Member Functions | |
PNMImage () | |
PNMImage (const Filename &filename, PNMFileType *type=NULL) | |
PNMImage (int x_size, int y_size, int num_channels=3, xelval maxval=255, PNMFileType *type=NULL) | |
PNMImage (const PNMImage ©) | |
void | operator= (const PNMImage ©) |
~PNMImage () | |
xelval | clamp_val (int input_value) const |
A handy function to clamp values to [0..get_maxval()]. | |
xelval | to_val (double input_value) const |
A handy function to scale values from [0..1] to [0..get_maxval()]. | |
double | from_val (xelval input_value) const |
A handy function to scale values from [0..get_maxval()] to [0..1]. | |
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 | 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 | 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. | |
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. | |
bool | read (const Filename &filename, PNMFileType *type=NULL) |
Reads the indicated image filename. | |
bool | read (PNMReader *reader) |
This flavor of read() uses an already-existing PNMReader to read the image file. | |
bool | write (const Filename &filename, PNMFileType *type=NULL) const |
Writes the image to the indicated filename. | |
bool | write (PNMWriter *writer) const |
This flavor of write() uses an already-existing PNMWriter to write the image file. | |
bool | is_valid () const |
Returns true if the image has been read in or correctly initialized with a height and width. | |
void | set_num_channels (int num_channels) |
Changes the number of channels associated with the image. | |
void | set_color_type (ColorType color_type) |
Translates the image to or from grayscale, color, or four-color mode. | |
void | add_alpha () |
Adds an alpha channel to the image, if it does not already have one. | |
void | remove_alpha () |
Removes the image's alpha channel, if it exists. | |
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_rgb () |
Converts the image from grayscale to RGB. | |
void | set_maxval (xelval maxval) |
Rescales the image to the indicated maxval. | |
const xel & | get_xel_val (int x, int y) const |
Returns the RGB color at the indicated pixel. | |
void | set_xel_val (int x, int y, const xel &value) |
Changes the RGB color at the indicated pixel. | |
void | set_xel_val (int x, int y, xelval r, xelval g, xelval b) |
Changes the RGB color at the indicated pixel. | |
void | set_xel_val (int x, int y, xelval gray) |
Changes all three color components at the indicated pixel to the same value. | |
xelval | get_red_val (int x, int y) const |
Returns the red 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_blue_val (int x, int y) const |
Returns the blue component color at the indicated pixel. | |
xelval | get_gray_val (int x, int y) const |
Returns the gray component color at the indicated pixel. | |
xelval | get_alpha_val (int x, int y) const |
Returns the alpha component color 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_green_val (int x, int y, xelval g) |
Sets the green 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_gray_val (int x, int y, xelval gray) |
Sets the gray component color at the indicated pixel. | |
void | set_alpha_val (int x, int y, xelval a) |
Sets the alpha component color only at the indicated pixel. | |
xelval | get_channel_val (int x, int y, int channel) const |
Returns 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. | |
RGBColord | get_xel (int x, int y) const |
Returns 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 (int x, int y, double r, double g, double b) |
Changes the RGB color at the indicated pixel. | |
void | set_xel (int x, int y, double gray) |
Changes all three color components at the indicated pixel to the same value. | |
double | get_red (int x, int y) const |
Returns the red component color at the indicated pixel. | |
double | get_green (int x, int y) const |
Returns the green component color at the indicated pixel. | |
double | get_blue (int x, int y) const |
Returns the blue component color at the indicated pixel. | |
double | get_gray (int x, int y) const |
Returns the gray component color at the indicated pixel. | |
double | get_alpha (int x, int y) const |
Returns the alpha component color at the indicated pixel. | |
void | set_red (int x, int y, double r) |
Sets the red component color only 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_blue (int x, int y, double b) |
Sets the blue component color only at the indicated pixel. | |
void | set_gray (int x, int y, double gray) |
Sets the gray component color at the indicated pixel. | |
void | set_alpha (int x, int y, double a) |
Sets the alpha component color only at the indicated pixel. | |
double | get_channel (int x, int y, int channel) const |
Returns the nth component color at the indicated pixel. | |
void | set_channel (int x, int y, int channel, double value) |
Sets the nth component color at the indicated pixel. | |
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) const |
This flavor of get_bright() works correctly only for color images. | |
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. | |
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. | |
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. | |
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 | 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 | 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 | box_filter_from (double radius, const PNMImage ©) |
Makes a resized copy of the indicated image into this one using the indicated filter. | |
void | gaussian_filter_from (double radius, const PNMImage ©) |
Makes a resized copy of the indicated image into this one using the indicated filter. | |
void | quick_filter_from (const PNMImage ©, int xborder=0, int yborder=0) |
Resizes from the given image, with a fixed radius of 0.5. | |
ColorType | get_color_type () const |
Returns the image type of the image, as an enumerated value. | |
int | get_num_channels () const |
Returns the number of channels in the image. | |
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 | has_alpha () const |
Returns true if the image includes an alpha channel, false otherwise. | |
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_x_size () const |
Returns the number of pixels in the X direction. | |
int | get_y_size () const |
Returns the number of pixels in the Y direction. | |
bool | has_type () const |
Returns true if the PNMImageHeader knows what type it is, false otherwise. | |
PNMFileType * | get_type () const |
If the file type is known (e.g. | |
void | set_type (PNMFileType *type) |
Sets the file type of this PNMImage. | |
bool | read_header (const Filename &filename, PNMFileType *type=NULL) |
Opens up the image file and tries to read its header information to determine its size, number of channels, etc. | |
PNMReader * | make_reader (const Filename &filename, PNMFileType *type=NULL) 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) 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. | |
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. | |
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. | |
void | output (ostream &out) const |
Static Public Member Functions | |
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. | |
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. | |
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 Attributes | |
int | _x_size |
int | _y_size |
int | _num_channels |
xelval | _maxval |
PNMFileType * | _type |
Private Member Functions | |
void | allocate_array () |
Allocates the internal memory for the RGB or grayscale pixels in the image (except alpha). | |
void | allocate_alpha () |
Allocates the internal memory for the alpha pixels in the image. | |
xel * | row (int row) const |
Returns an array of xels corresponding to the nth row of the image. | |
xelval * | alpha_row (int row) const |
Returns an array of xelvals corresponding to the nth row of the alpha channel. | |
void | setup_rc () |
Sets the _default_rc,bc,gc values appropriately according to the color type of the image, so that get_bright() will return a meaningful value for both color and grayscale images. | |
Private Attributes | |
xel * | _array |
xelval * | _alpha |
double | _default_rc |
double | _default_gc |
double | _default_bc |
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 88 of file pnmImage.h.
|
Definition at line 65 of file pnmImageHeader.h. |
|
Definition at line 30 of file pnmImage.I. |
|
Definition at line 43 of file pnmImage.I. |
|
Definition at line 58 of file pnmImage.I. References _alpha, _array, copy_from(), INLINE, and NULL. |
|
Definition at line 74 of file pnmImage.I. References copy_from(), and INLINE. |
|
Definition at line 103 of file pnmImage.I. References clamp_val(), PNMImageHeader::get_maxval(), INLINE, and xelval. |
|
Adds an alpha channel to the image, if it does not already have one. The alpha channel is initialized to zeros. Definition at line 267 of file pnmImage.I. References INLINE, PPM_ASSIGN, row(), x, and y. |
|
Allocates the internal memory for the alpha pixels in the image.
Definition at line 1038 of file pnmImage.I. Referenced by clear(), and copy_from(). |
|
Allocates the internal memory for the RGB or grayscale pixels in the image (except alpha).
Definition at line 1023 of file pnmImage.I. Referenced by copy_from(). |
|
Sets the entire alpha channel to the given level.
Definition at line 209 of file pnmImage.I. |
|
Sets the entire alpha channel to the given level.
Definition at line 166 of file pnmImage.cxx. Referenced by fill(). |
|
Returns an array of xelvals corresponding to the nth row of the alpha channel.
Definition at line 1068 of file pnmImage.I. Referenced by get_green_val(), and set_xel_val(). |
|
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 564 of file pnmImage.cxx. References _default_bc. |
|
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 943 of file pnmImage.I. Referenced by get_blue(). |
|
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 990 of file pnmImage.I. |
|
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 455 of file pnm-image-filter.cxx. References filter_image(), gaussian_filter_impl(), and width. |
|
A handy function to clamp values to [0..get_maxval()].
Definition at line 119 of file pnmImage.I. References PNMImageHeader::get_maxval(), and INLINE. Referenced by ~PNMImage(). |
|
This flavor of clear() reinitializes the image to an empty (black) image with the given dimensions.
Definition at line 65 of file pnmImage.cxx. References _alpha, PNMImageHeader::_x_size, PNMImageHeader::_y_size, allocate_alpha(), and xelval. |
|
Frees all memory allocated for the image, and clears all its parameters (size, color, type, etc).
Definition at line 38 of file pnmImage.cxx. Referenced by copy_from(), and PNMImage(). |
|
Makes this image become a copy of the other image.
Definition at line 96 of file pnmImage.cxx. References allocate_alpha(), allocate_array(), clear(), PNMImageHeader::has_alpha(), PNMImageHeader::operator=(), and setup_rc(). Referenced by PNMImage(). |
|
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 124 of file pnmImage.cxx. References PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), set_xel_val(), x, and y. |
|
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 618 of file pnmImage.cxx. |
|
Sets the entire image (except the alpha channel) to the given grayscale level.
Definition at line 181 of file pnmImage.I. |
|
Sets the entire image (except the alpha channel) to the given color.
Definition at line 164 of file pnmImage.I. References alpha_fill_val(), PNMImageHeader::get_maxval(), INLINE, and xelval. |
|
Sets the entire image (except the alpha channel) to the given grayscale level.
Definition at line 196 of file pnmImage.I. |
|
Sets the entire image (except the alpha channel) to the given color.
Definition at line 147 of file pnmImage.cxx. Referenced by from_val(). |
|
A handy function to scale values from [0..get_maxval()] to [0..1].
Definition at line 149 of file pnmImage.I. References fill_val(), gray, and INLINE. Referenced by get_blue_val(), get_green(), get_red(), set_green_val(), set_red_val(), and set_xel(). |
|
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 1007 of file pnmImage.I. |
|
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 476 of file pnm-image-filter.cxx. References get_alpha_val(), x, and y. |
|
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 713 of file pnmImage.I. |
|
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 459 of file pnmImage.I. Referenced by gaussian_filter_from(), get_green(), and set_color_type(). |
|
Returns the blue component color at the indicated pixel. The value returned is a double in the range 0..1. Definition at line 671 of file pnmImage.I. |
|
Returns the blue component color at the indicated pixel. The value returned is in the range 0..maxval. Definition at line 417 of file pnmImage.I. References from_val(), get_green_val(), get_red_val(), INLINE, RGBColord, x, and y. Referenced by get_green(), get_red(), set_color_type(), and set_green_val(). |
|
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 919 of file pnmImage.I. |
|
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 898 of file pnmImage.I. |
|
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 879 of file pnmImage.I. Referenced by write(). |
|
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 835 of file pnmImage.I. |
|
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 476 of file pnmImage.cxx. References set_alpha(), set_xel(), x, and y. Referenced by set_xel(). |
|
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 95 of file pnmImageHeader.I. References PNMImageHeader::CT_grayscale, PNMImageHeader::CT_two_channel, and INLINE. Referenced by PNMImageHeader::get_num_channels(), write(), and PixelBuffer::write(). |
|
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 694 of file pnmImage.I. |
|
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 440 of file pnmImage.I. References INLINE, set_xel_val(), to_val(), x, and y. Referenced by set_color_type(), and write(). |
|
Returns the green component color at the indicated pixel. The value returned is a double in the range 0..1. Definition at line 654 of file pnmImage.I. References from_val(), get_alpha_val(), get_blue_val(), get_green_val(), get_red_val(), INLINE, x, and y. |
|
Returns the green component color at the indicated pixel. The value returned is in the range 0..maxval. Definition at line 402 of file pnmImage.I. References alpha_row(), INLINE, x, and y. Referenced by get_blue_val(), get_green(), get_red(), make_grayscale(), set_color_type(), and set_red_val(). |
|
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 203 of file pnmImageHeader.I. References PNMImageHeader::_type. Referenced by clamp_val(), fill(), operator=(), and ~PNMImage(). |
|
Returns the number of channels in the image.
Definition at line 109 of file pnmImageHeader.I. References PNMImageHeader::get_color_type(), INLINE, and PNMImageHeader::is_grayscale(). Referenced by PixelBuffer::write(). |
|
Returns the red component color at the indicated pixel. The value returned is a double in the range 0..1. Definition at line 637 of file pnmImage.I. References from_val(), get_blue_val(), get_green_val(), get_red_val(), INLINE, x, and y. |
|
Returns the red component color at the indicated pixel. The value returned is in the range 0..maxval. Definition at line 387 of file pnmImage.I. References gray, INLINE, PPM_PUTB, row(), x, and y. Referenced by get_blue_val(), get_green(), get_red(), and set_color_type(). |
|
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 269 of file pnmImageHeader.I. |
|
Returns the number of pixels in the X direction. This is one more than the largest allowable X coordinate. Definition at line 220 of file pnmImageHeader.I. Referenced by copy_header_from(), down_to_power_2(), Texture::read(), WindowFramework::set_background_type(), set_color_type(), and write(). |
|
Returns the RGB color at the indicated pixel. Each component is a double in the range 0..1. Definition at line 571 of file pnmImage.I. References INLINE, set_gray_val(), to_val(), x, and y. |
|
Returns the RGB color at the indicated pixel. Each component is in the range 0..maxval. Definition at line 325 of file pnmImage.I. References INLINE, PPM_GETB, x, xelval, and y. Referenced by make_grayscale(), and make_rgb(). |
|
Returns the number of pixels in the Y direction. This is one more than the largest allowable Y coordinate. Definition at line 237 of file pnmImageHeader.I. Referenced by copy_header_from(), down_to_power_2(), Texture::read(), WindowFramework::set_background_type(), set_color_type(), and write(). |
|
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 184 of file pnmImageHeader.I. References PNMImageHeader::_type, INLINE, and NULL. Referenced by copy_from(), set_color_type(), and write(). |
|
This static variant of has_alpha() returns true if the indicated image type includes an alpha channel, false otherwise.
Definition at line 165 of file pnmImageHeader.I. References PNMImageHeader::_x_size, and INLINE. Referenced by filter_image(), and WindowFramework::set_background_type(). |
|
Returns true if the PNMImageHeader knows what type it is, false otherwise.
Definition at line 252 of file pnmImageHeader.I. |
|
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 148 of file pnmImageHeader.I. References PNMImageHeader::_maxval, INLINE, and xelval. Referenced by PNMImageHeader::get_num_channels(), set_color_type(), write(), PNMFileTypeTGA::Writer::Writer(), and PNMFileTypeAlias::Writer::Writer(). |
|
This static variant of is_grayscale() returns true if the indicated image type represents a grayscale image, false otherwise.
Definition at line 127 of file pnmImageHeader.I. References PNMImageHeader::CT_four_channel, PNMImageHeader::CT_two_channel, and INLINE. Referenced by filter_image(). |
|
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 228 of file pnmImage.I. References _default_bc, _default_gc, _default_rc, and make_grayscale(). |
|
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 397 of file pnmImage.cxx. References PNMImageHeader::_num_channels, get_green_val(), x, and y. |
|
Converts the image from RGB to grayscale. Any alpha channel, if present, is left undisturbed. Definition at line 295 of file pnmImage.I. References get_xel_val(), PPM_GETR, x, and y. Referenced by is_valid(). |
|
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 189 of file pnmImageHeader.cxx. References PNMImageHeader::_type, PNMFileType::get_name(), and NULL. |
|
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 84 of file pnmImageHeader.cxx. |
|
Converts the image from grayscale to RGB. Any alpha channel, if present, is left undisturbed. Definition at line 310 of file pnmImage.I. References get_xel_val(), INLINE, PPM_GETB, x, xelval, and y. |
|
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 386 of file pnmImageHeader.cxx. |
|
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 299 of file pnmImageHeader.cxx. References PNMImageHeader::_type, Filename::empty(), PNMFileType::get_name(), PNMFileTypeRegistry::get_ptr(), PNMFileTypeRegistry::get_type_from_extension(), PNMFileType::make_writer(), NULL, and writer(). |
|
Definition at line 91 of file pnmImage.I. References PNMImageHeader::get_maxval(), INLINE, and xelval. |
|
Allows the PNMImage to appear to be a 2-d array of xels.
Definition at line 973 of file pnmImage.I. |
|
Allows the PNMImage to appear to be a 2-d array of xels.
Definition at line 958 of file pnmImage.I. |
|
Definition at line 474 of file pnmImageHeader.cxx. |
|
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 594 of file pnm-image-filter.cxx. References xelval. Referenced by GLGraphicsStateGuardian::enable_clip_plane(). |
|
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 228 of file pnmImage.cxx. |
|
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 193 of file pnmImage.cxx. References reader(). Referenced by PNMImage(), Texture::read(), and Texture::Texture(). |
|
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 47 of file pnmImageHeader.cxx. Referenced by WindowFramework::set_background_type(). |
|
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 454 of file pnmImageHeader.cxx. |
|
Removes the image's alpha channel, if it exists.
Definition at line 280 of file pnmImage.I. |
|
Returns an array of xels corresponding to the nth row of the image.
Definition at line 1053 of file pnmImage.I. Referenced by add_alpha(), get_gray(), get_red_val(), remove_alpha(), set_num_channels(), and set_xel_val(). |
|
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 810 of file pnmImage.I. Referenced by get_channel_val(). |
|
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 556 of file pnmImage.I. References INLINE, set_blue_val(), to_val(), x, and y. Referenced by set_color_type(), set_maxval(), and set_xel(). |
|
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 764 of file pnmImage.I. References _alpha, PNMImageHeader::_x_size, INLINE, xelval, and y. |
|
Sets the blue component color only at the indicated pixel. The value given should be in the range 0..maxval. Definition at line 510 of file pnmImage.I. Referenced by set_alpha_val(), set_color_type(), and set_maxval(). |
|
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 860 of file pnmImage.I. |
|
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 520 of file pnmImage.cxx. Referenced by set_xel(). |
|
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 340 of file pnmImage.cxx. References PNMImageHeader::_maxval, 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(), nassertv, set_alpha_val(), set_blue_val(), set_gray_val(), set_green_val(), set_red_val(), x, xelval, and y. |
|
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 791 of file pnmImage.I. Referenced by PixelBuffer::store(), and write(). |
|
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 537 of file pnmImage.I. References INLINE, set_green_val(), to_val(), x, and y. Referenced by get_xel(), and set_color_type(). |
|
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 747 of file pnmImage.I. References _alpha, PNMImageHeader::_x_size, PNMImageHeader::_y_size, and xelval. |
|
Sets the green component color only at the indicated pixel. The value given should be in the range 0..maxval. Definition at line 493 of file pnmImage.I. References from_val(), get_blue_val(), INLINE, x, and y. Referenced by set_color_type(), set_gray_val(), and set_maxval(). |
|
Rescales the image to the indicated maxval.
Definition at line 421 of file pnmImage.cxx. References PNMImageHeader::_num_channels, nassertv, set_alpha_val(), set_blue_val(), set_green_val(), set_red_val(), x, and y. |
|
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 249 of file pnmImage.I. |
|
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 730 of file pnmImage.I. References _array, PNMImageHeader::_x_size, PNMImageHeader::_y_size, and INLINE. |
|
Sets the red component color only at the indicated pixel. The value given should be in the range 0..maxval. Definition at line 476 of file pnmImage.I. References from_val(), get_green_val(), INLINE, x, and y. Referenced by set_color_type(), and set_maxval(). |
|
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 292 of file pnmImageHeader.I. |
|
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 620 of file pnmImage.I. References set_channel_val(), to_val(), x, and y. |
|
Changes the RGB color at the indicated pixel. Each component is a double in the range 0..1. Definition at line 603 of file pnmImage.I. References from_val(), get_channel_val(), INLINE, x, and y. |
|
Changes the RGB color at the indicated pixel. Each component is a double in the range 0..1. Definition at line 588 of file pnmImage.I. References set_alpha_val(), to_val(), x, and y. Referenced by get_channel_val(). |
|
Changes all three color components at the indicated pixel to the same value. The value is in the range 0..maxval. Definition at line 372 of file pnmImage.I. |
|
Changes the RGB color at the indicated pixel. Each component is in the range 0..maxval. Definition at line 355 of file pnmImage.I. |
|
Changes the RGB color at the indicated pixel. Each component is in the range 0..maxval. Definition at line 340 of file pnmImage.I. References alpha_row(), INLINE, x, xelval, and y. Referenced by copy_header_from(), get_gray_val(), and write(). |
|
Sets the _default_rc,bc,gc values appropriately according to the color type of the image, so that get_bright() will return a meaningful value for both color and grayscale images.
Definition at line 674 of file pnmImage.cxx. Referenced by copy_from(). |
|
A handy function to scale values from [0..1] to [0..get_maxval()].
Definition at line 134 of file pnmImage.I. Referenced by get_gray_val(), get_xel(), set_alpha_val(), set_gray_val(), and set_xel(). |
|
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 302 of file pnmImage.cxx. |
|
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 270 of file pnmImage.cxx. References _alpha, get_bright(), PNMImageHeader::get_color_type(), get_gray_val(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), PNMImageHeader::has_alpha(), PNMImageHeader::is_grayscale(), nassertv, NULL, set_gray(), set_xel_val(), x, and y. Referenced by PixelBuffer::read(). |
|
Definition at line 230 of file pnmImage.h. Referenced by clear(), PNMImage(), set_blue(), set_green(), and write(). |
|
Definition at line 229 of file pnmImage.h. Referenced by fill(), PNMImage(), and set_red(). |
|
Definition at line 231 of file pnmImage.h. Referenced by blend(), and is_valid(). |
|
Definition at line 231 of file pnmImage.h. Referenced by is_valid(). |
|
Definition at line 231 of file pnmImage.h. Referenced by is_valid(). |
|
|
Definition at line 113 of file pnmImageHeader.h. Referenced by make_grayscale(), PNMWriter::set_color_type(), set_maxval(), PNMFileTypeSGI::Writer::write_channels(), PNMFileTypeSGI::Writer::write_rgb_header(), PNMFileTypeSGI::Writer::write_table(), and PNMImageHeader::~PNMImageHeader(). |
|
Reimplemented in PNMReader, and PNMWriter. Definition at line 115 of file pnmImageHeader.h. Referenced by PNMImageHeader::get_maxval(), PNMImageHeader::has_alpha(), PNMImageHeader::make_reader(), PNMImageHeader::make_writer(), and PNMImageHeader::PNMImageHeader(). |
|
|