PNMImage
from panda3d.core import PNMImage
- class PNMImage
Bases:
PNMImageHeader
The name of this class derives from the fact that we originally implemented it as a layer on top of the “pnm library”, based on netpbm, which was built to implement pbm, pgm, and pbm files, and is the underlying support of a number of public-domain image file converters. Nowadays we are no longer derived directly from the pnm library, mainly to allow support of C++ iostreams instead of the C stdio FILE interface.
Conceptually, a PNMImage is a two-dimensional array of xels, which are the PNM-defined generic pixel type. Each xel may have a red, green, and blue component, or (if the image is grayscale) a gray component. The image may be read in, the individual xels manipulated, and written out again, or a black image may be constructed from scratch.
A PNMImage has a color space and a maxval, the combination of which defines how a floating-point linear color value is encoded as an integer value in memory. The functions ending in _val operate on encoded colors, whereas the regular ones work with linear floating-point values. All operations are color space correct unless otherwise specified.
The image is of size XSize() by YSize() xels, numbered from top to bottom, left to right, beginning at zero.
Files can be specified by filename, or by an iostream pointer. The filename “-” refers to stdin or stdout.
This class is not inherently thread-safe; use it from a single thread or protect access using a mutex.
Inheritance diagram
- class CRow
Bases:
DTOOL_SUPER_BASE
Provides an accessor for reading the contents of one row of the image in- place.
- __init__(*args, **kwargs)
- getAlphaVal()
C++ Interface: get_alpha_val(CRow self, int x)
- /**
Fetch the alpha value at the given column in the row.
*/
- getXelVal()
C++ Interface: get_xel_val(CRow self, int x)
- /**
Fetch the pixel at the given column in the row.
*/
- class Row
Bases:
DTOOL_SUPER_BASE
Provides an accessor for reading or writing the contents of one row of the image in-place.
- __init__(*args, **kwargs)
- getAlphaVal()
C++ Interface: get_alpha_val(Row self, int x)
- /**
Fetch the alpha value at the given column in the row.
*/
- getXelVal()
C++ Interface: get_xel_val(const Row self, int x)
- /**
Fetch the pixel at the given column in the row.
*/
- get_alpha_val()
C++ Interface: get_alpha_val(Row self, int x)
- /**
Fetch the alpha value at the given column in the row.
*/
- get_xel_val()
C++ Interface: get_xel_val(const Row self, int x)
- /**
Fetch the pixel at the given column in the row.
*/
- setAlphaVal()
C++ Interface: set_alpha_val(const Row self, int x, int v)
- /**
Set the alpha value at the given column in the row.
*/
- setXelVal()
C++ Interface: set_xel_val(const Row self, int x, const pixel v)
- /**
Set the pixel at the given column in the row.
*/
- __init__(*args, **kwargs)
- addAlpha()
C++ Interface: add_alpha(const PNMImage self)
- /**
Adds an alpha channel to the image, if it does not already have one. The
alpha channel is initialized to zeros.
*/
- addSubImage()
C++ Interface: add_sub_image(const PNMImage self, const PNMImage copy, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size, float pixel_scale)
- /**
Behaves like copy_sub_image(), except the copy pixels are added to the
pixels of the destination, after scaling by the specified pixel_scale.
Unlike blend_sub_image(), the alpha channel is not treated specially.
*/
- add_alpha()
C++ Interface: add_alpha(const PNMImage self)
- /**
Adds an alpha channel to the image, if it does not already have one. The
alpha channel is initialized to zeros.
*/
- add_sub_image()
C++ Interface: add_sub_image(const PNMImage self, const PNMImage copy, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size, float pixel_scale)
- /**
Behaves like copy_sub_image(), except the copy pixels are added to the
pixels of the destination, after scaling by the specified pixel_scale.
Unlike blend_sub_image(), the alpha channel is not treated specially.
*/
- alphaFill()
C++ Interface: alpha_fill(const PNMImage self, float alpha)
- /**
Sets the entire alpha channel to the given level.
*/
- alphaFillVal()
C++ Interface: alpha_fill_val(const PNMImage self, int alpha)
- /**
Sets the entire alpha channel to the given level.
*/
- alpha_fill()
C++ Interface: alpha_fill(const PNMImage self, float alpha)
- /**
Sets the entire alpha channel to the given level.
*/
- alpha_fill_val()
C++ Interface: alpha_fill_val(const PNMImage self, int alpha)
- /**
Sets the entire alpha channel to the given level.
*/
- applyExponent()
C++ Interface: apply_exponent(const PNMImage self, float gray_exponent) apply_exponent(const PNMImage self, float gray_exponent, float alpha_exponent) apply_exponent(const PNMImage self, float red_exponent, float green_exponent, float blue_exponent) apply_exponent(const PNMImage self, float red_exponent, float green_exponent, float blue_exponent, float alpha_exponent)
- /**
Adjusts each channel of the image by raising the corresponding component
value to the indicated exponent, such that L’ = L ^ exponent.
*/
- /**
Adjusts each channel of the image by raising the corresponding component
value to the indicated exponent, such that L’ = L ^ exponent.
*/
- /**
Adjusts each channel of the image by raising the corresponding component
value to the indicated exponent, such that L’ = L ^ exponent. For a
grayscale image, the blue_exponent value is used for the grayscale value,
and red_exponent and green_exponent are unused.
*/
- /**
Adjusts each channel of the image by raising the corresponding component
value to the indicated exponent, such that L’ = L ^ exponent. For a
grayscale image, the blue_exponent value is used for the grayscale value,
and red_exponent and green_exponent are unused.
*/
- apply_exponent()
C++ Interface: apply_exponent(const PNMImage self, float gray_exponent) apply_exponent(const PNMImage self, float gray_exponent, float alpha_exponent) apply_exponent(const PNMImage self, float red_exponent, float green_exponent, float blue_exponent) apply_exponent(const PNMImage self, float red_exponent, float green_exponent, float blue_exponent, float alpha_exponent)
- /**
Adjusts each channel of the image by raising the corresponding component
value to the indicated exponent, such that L’ = L ^ exponent.
*/
- /**
Adjusts each channel of the image by raising the corresponding component
value to the indicated exponent, such that L’ = L ^ exponent.
*/
- /**
Adjusts each channel of the image by raising the corresponding component
value to the indicated exponent, such that L’ = L ^ exponent. For a
grayscale image, the blue_exponent value is used for the grayscale value,
and red_exponent and green_exponent are unused.
*/
- /**
Adjusts each channel of the image by raising the corresponding component
value to the indicated exponent, such that L’ = L ^ exponent. For a
grayscale image, the blue_exponent value is used for the grayscale value,
and red_exponent and green_exponent are unused.
*/
- assign()
C++ Interface: assign(const PNMImage self, const PNMImage copy)
- blend()
C++ Interface: blend(const PNMImage self, int x, int y, const LVecBase3f val, float alpha) blend(const PNMImage self, int x, int y, float r, float g, float b, float alpha)
- /**
Smoothly blends the indicated pixel value in with whatever was already in
the image, based on the given alpha value. An alpha of 1.0 is fully opaque
and completely replaces whatever was there previously; alpha of 0.0 is
fully transparent and does nothing.
*/
- /**
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.
*/
- blendSubImage()
C++ Interface: blend_sub_image(const PNMImage self, const PNMImage copy, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size, float pixel_scale)
- /**
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().
*/
- blend_sub_image()
C++ Interface: blend_sub_image(const PNMImage self, const PNMImage copy, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size, float pixel_scale)
- /**
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().
*/
- boxFilter()
C++ Interface: box_filter(const PNMImage self, float radius)
- /**
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.
*/
- boxFilterFrom()
C++ Interface: box_filter_from(const PNMImage self, float radius, 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.
*/
- box_filter()
C++ Interface: box_filter(const PNMImage self, float radius)
- /**
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.
*/
- box_filter_from()
C++ Interface: box_filter_from(const PNMImage self, float radius, 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.
*/
- clampVal()
C++ Interface: clamp_val(PNMImage self, int input_value)
- /**
A handy function to clamp values to [0..get_maxval()].
*/
- clamp_val()
C++ Interface: clamp_val(PNMImage self, int input_value)
- /**
A handy function to clamp values to [0..get_maxval()].
*/
- clear()
C++ Interface: clear(const PNMImage self) clear(const PNMImage self, int x_size, int y_size, int num_channels, int maxval, PNMFileType type, int color_space)
- clearReadSize()
C++ Interface: clear_read_size(const PNMImage self)
- /**
Undoes the effect of a previous call to set_read_size().
*/
- clear_read_size()
C++ Interface: clear_read_size(const PNMImage self)
- /**
Undoes the effect of a previous call to set_read_size().
*/
- copyChannel()
C++ Interface: copy_channel(const PNMImage self, const PNMImage copy, int src_channel, int dest_channel) copy_channel(const PNMImage self, const PNMImage copy, int xto, int yto, int cto, int xfrom, int yfrom, int cfrom, int x_size, int y_size)
- copyChannelBits()
C++ Interface: copy_channel_bits(const PNMImage self, const PNMImage copy, int src_channel, int dest_channel, int src_mask, int right_shift)
- /**
Copies some subset of the bits of the specified channel from one image into
some subset of the bits of the specified channel in another image. Images
must be the same size.
If right_shift is negative, it means a left shift.
*/
- copyFrom()
C++ Interface: copy_from(const PNMImage self, const PNMImage copy)
- /**
Makes this image become a copy of the other image.
*/
- copyHeaderFrom()
C++ Interface: copy_header_from(const PNMImage self, 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.
*/
- copySubImage()
C++ Interface: copy_sub_image(const PNMImage self, const PNMImage copy, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size)
- /**
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.
*/
- copy_channel()
C++ Interface: copy_channel(const PNMImage self, const PNMImage copy, int src_channel, int dest_channel) copy_channel(const PNMImage self, const PNMImage copy, int xto, int yto, int cto, int xfrom, int yfrom, int cfrom, int x_size, int y_size)
- copy_channel_bits()
C++ Interface: copy_channel_bits(const PNMImage self, const PNMImage copy, int src_channel, int dest_channel, int src_mask, int right_shift)
- /**
Copies some subset of the bits of the specified channel from one image into
some subset of the bits of the specified channel in another image. Images
must be the same size.
If right_shift is negative, it means a left shift.
*/
- copy_from()
C++ Interface: copy_from(const PNMImage self, const PNMImage copy)
- /**
Makes this image become a copy of the other image.
*/
- copy_header_from()
C++ Interface: copy_header_from(const PNMImage self, 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.
*/
- copy_sub_image()
C++ Interface: copy_sub_image(const PNMImage self, const PNMImage copy, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size)
- /**
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.
*/
- darkenSubImage()
C++ Interface: darken_sub_image(const PNMImage self, const PNMImage copy, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size, float pixel_scale)
- /**
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.
*/
- darken_sub_image()
C++ Interface: darken_sub_image(const PNMImage self, const PNMImage copy, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size, float pixel_scale)
- /**
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.
*/
- doFillDistance()
C++ Interface: do_fill_distance(const PNMImage self, int xi, int yi, int d)
- /**
Recursively fills in the minimum distance measured from a certain set of
points into the gray channel.
*/
- do_fill_distance()
C++ Interface: do_fill_distance(const PNMImage self, int xi, int yi, int d)
- /**
Recursively fills in the minimum distance measured from a certain set of
points into the gray channel.
*/
- expandBorder()
C++ Interface: expand_border(const PNMImage self, int left, int right, int bottom, int top, const LVecBase4f 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.
*/
- expand_border()
C++ Interface: expand_border(const PNMImage self, int left, int right, int bottom, int top, const LVecBase4f 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.
*/
- fill()
C++ Interface: fill(const PNMImage self) fill(const PNMImage self, float gray) fill(const PNMImage self, float red, float green, float blue)
- fillDistanceInside()
C++ Interface: fill_distance_inside(const PNMImage self, const PNMImage mask, float threshold, int radius, bool shrink_from_border)
- /**
Replaces this image with a grayscale image whose gray channel represents
the linear Manhattan distance from the nearest dark pixel in the given mask
image, up to the specified radius value (which also becomes the new
maxval). radius may range from 0 to maxmaxval; smaller values will compute
faster. A dark pixel is defined as one whose pixel value is < threshold.
If shrink_from_border is true, then the mask image is considered to be
surrounded by a border of dark pixels; otherwise, the border isn’t
considered.
This can be used, in conjunction with threshold, to shrink a mask image
inwards by a certain number of pixels.
The mask image may be the same image as this one, in which case it is
destructively modified by this process.
*/
- fillDistanceOutside()
C++ Interface: fill_distance_outside(const PNMImage self, const PNMImage mask, float threshold, int radius)
- /**
Replaces this image with a grayscale image whose gray channel represents
the linear Manhattan distance from the nearest white pixel in the given
mask image, up to the specified radius value (which also becomes the new
maxval). radius may range from 0 to maxmaxval; smaller values will compute
faster. A white pixel is defined as one whose pixel value is >= threshold.
This can be used, in conjunction with threshold, to grow a mask image
outwards by a certain number of pixels.
The mask image may be the same image as this one, in which case it is
destructively modified by this process.
*/
- fillVal()
C++ Interface: fill_val(const PNMImage self) fill_val(const PNMImage self, int gray) fill_val(const PNMImage self, int red, int green, int blue)
- fill_distance_inside()
C++ Interface: fill_distance_inside(const PNMImage self, const PNMImage mask, float threshold, int radius, bool shrink_from_border)
- /**
Replaces this image with a grayscale image whose gray channel represents
the linear Manhattan distance from the nearest dark pixel in the given mask
image, up to the specified radius value (which also becomes the new
maxval). radius may range from 0 to maxmaxval; smaller values will compute
faster. A dark pixel is defined as one whose pixel value is < threshold.
If shrink_from_border is true, then the mask image is considered to be
surrounded by a border of dark pixels; otherwise, the border isn’t
considered.
This can be used, in conjunction with threshold, to shrink a mask image
inwards by a certain number of pixels.
The mask image may be the same image as this one, in which case it is
destructively modified by this process.
*/
- fill_distance_outside()
C++ Interface: fill_distance_outside(const PNMImage self, const PNMImage mask, float threshold, int radius)
- /**
Replaces this image with a grayscale image whose gray channel represents
the linear Manhattan distance from the nearest white pixel in the given
mask image, up to the specified radius value (which also becomes the new
maxval). radius may range from 0 to maxmaxval; smaller values will compute
faster. A white pixel is defined as one whose pixel value is >= threshold.
This can be used, in conjunction with threshold, to grow a mask image
outwards by a certain number of pixels.
The mask image may be the same image as this one, in which case it is
destructively modified by this process.
*/
- fill_val()
C++ Interface: fill_val(const PNMImage self) fill_val(const PNMImage self, int gray) fill_val(const PNMImage self, int red, int green, int blue)
- flip()
C++ Interface: flip(const PNMImage self, bool flip_x, bool flip_y, bool transpose)
- /**
Reverses, transposes, and/or rotates the image in-place according to the
specified parameters. If flip_x is true, the x axis is reversed; if flip_y
is true, the y axis is reversed. Then, if transpose is true, the x and y
axes are exchanged. These parameters can be used to select any combination
of 90-degree or 180-degree rotations and flips.
*/
- fromAlphaVal()
C++ Interface: from_alpha_val(PNMImage self, int input_value)
- /**
A handy function to scale alpha values from [0..get_maxval()] to [0..1].
*/
- fromVal()
C++ Interface: from_val(PNMImage self, const pixel input_value) from_val(PNMImage self, int input_value)
- from_alpha_val()
C++ Interface: from_alpha_val(PNMImage self, int input_value)
- /**
A handy function to scale alpha values from [0..get_maxval()] to [0..1].
*/
- from_val()
C++ Interface: from_val(PNMImage self, const pixel input_value) from_val(PNMImage self, int input_value)
- gammaCorrect()
C++ Interface: gamma_correct(const PNMImage self, float from_gamma, float to_gamma)
- /**
Assuming the image was constructed with a gamma curve of from_gamma in the
RGB channels, converts it to an image with a gamma curve of to_gamma in the
RGB channels. Does not affect the alpha channel.
*/
- gammaCorrectAlpha()
C++ Interface: gamma_correct_alpha(const PNMImage self, float from_gamma, float to_gamma)
- /**
Assuming the image was constructed with a gamma curve of from_gamma in the
alpha channel, converts it to an image with a gamma curve of to_gamma in
the alpha channel. Does not affect the RGB channels.
*/
- gamma_correct()
C++ Interface: gamma_correct(const PNMImage self, float from_gamma, float to_gamma)
- /**
Assuming the image was constructed with a gamma curve of from_gamma in the
RGB channels, converts it to an image with a gamma curve of to_gamma in the
RGB channels. Does not affect the alpha channel.
*/
- gamma_correct_alpha()
C++ Interface: gamma_correct_alpha(const PNMImage self, float from_gamma, float to_gamma)
- /**
Assuming the image was constructed with a gamma curve of from_gamma in the
alpha channel, converts it to an image with a gamma curve of to_gamma in
the alpha channel. Does not affect the RGB channels.
*/
- gaussianFilter()
C++ Interface: gaussian_filter(const PNMImage self, float radius)
- /**
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.
*/
- gaussianFilterFrom()
C++ Interface: gaussian_filter_from(const PNMImage self, float radius, 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.
*/
- gaussian_filter()
C++ Interface: gaussian_filter(const PNMImage self, float radius)
- /**
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.
*/
- gaussian_filter_from()
C++ Interface: gaussian_filter_from(const PNMImage self, float radius, 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.
*/
- getAlpha()
C++ Interface: get_alpha(PNMImage self, int x, int 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 float in
the range 0..1.
*/
- getAlphaVal()
C++ Interface: get_alpha_val(PNMImage self, int x, int 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 in the
range 0..maxval and always linear.
*/
- getAverageGray()
C++ Interface: get_average_gray(PNMImage self)
- /**
Returns the average grayscale component of all of the pixels in the image.
*/
- getAverageXel()
C++ Interface: get_average_xel(PNMImage self)
- /**
Returns the average color of all of the pixels in the image.
*/
- getAverageXelA()
C++ Interface: get_average_xel_a(PNMImage self)
- /**
Returns the average color of all of the pixels in the image, including the
alpha channel.
*/
- getBlue()
C++ Interface: get_blue(PNMImage self, int x, int y)
- /**
Returns the blue component color at the indicated pixel. The value
returned is a linearized float in the range 0..1.
*/
- getBlueVal()
C++ Interface: get_blue_val(PNMImage self, int x, int y)
- /**
Returns the blue component color at the indicated pixel. The value
returned is in the range 0..maxval and encoded in the configured color
space.
*/
- getBright()
C++ Interface: get_bright(PNMImage self, int x, int y) get_bright(PNMImage self, int x, int y, float rc, float gc, float bc) get_bright(PNMImage self, int x, int y, float rc, float gc, float bc, float ac)
- /**
Returns the linear brightness of the given xel, as a linearized float in
the range 0..1. This flavor of get_bright() returns the correct grayscale
brightness level for both full-color and grayscale images.
*/
- /**
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.
*/
- /**
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.
*/
- getChannel()
C++ Interface: get_channel(PNMImage self, int x, int y, int channel)
- /**
Returns the nth component color at the indicated pixel. The channel index
should be in the range 0..(get_num_channels()-1). The channels are ordered
B, G, R, A. This is slightly less optimal than accessing the component
values directly by named methods. The value returned is a float in the
range 0..1.
*/
- getChannelVal()
C++ Interface: get_channel_val(PNMImage self, int x, int y, int channel)
- /**
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.
*/
- getColorSpace()
C++ Interface: get_color_space(PNMImage self)
- /**
Returns the color space in which the image is encoded.
*/
- getGray()
C++ Interface: get_gray(PNMImage self, int x, int y)
- /**
Returns the gray component color at the indicated pixel. This only has a
meaningful value for grayscale images; for other image types, this returns
the value of the blue channel only. However, also see the get_bright()
function. The value returned is a linearized float in the range 0..1.
*/
- getGrayVal()
C++ Interface: get_gray_val(PNMImage self, int x, int y)
- /**
Returns the gray component color at the indicated pixel. This only has a
meaningful value for grayscale images; for other image types, this returns
the value of the blue channel only. However, also see the get_bright()
function. The value returned is in the range 0..maxval and encoded in the
configured color space.
*/
- getGreen()
C++ Interface: get_green(PNMImage self, int x, int y)
- /**
Returns the green component color at the indicated pixel. The value
returned is a linearized float in the range 0..1.
*/
- getGreenVal()
C++ Interface: get_green_val(PNMImage self, int x, int y)
- /**
Returns the green component color at the indicated pixel. The value
returned is in the range 0..maxval and encoded in the configured color
space.
*/
- getPixel()
C++ Interface: get_pixel(PNMImage self, int x, int y)
- /**
Returns the (r, g, b, a) pixel value at the indicated pixel, using a
PixelSpec object.
*/
- getReadXSize()
C++ Interface: get_read_x_size(PNMImage self)
- /**
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).
*/
- getReadYSize()
C++ Interface: get_read_y_size(PNMImage self)
- /**
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).
*/
- getRed()
C++ Interface: get_red(PNMImage self, int x, int y)
- /**
Returns the red component color at the indicated pixel. The value returned
is a linearized float in the range 0..1.
*/
- getRedVal()
C++ Interface: get_red_val(PNMImage self, int x, int y)
- /**
Returns the red component color at the indicated pixel. The value returned
is in the range 0..maxval and encoded in the configured color space.
*/
- getXel()
C++ Interface: get_xel(PNMImage self, int x, int y)
- /**
Returns the RGB color at the indicated pixel. Each component is a
linearized float in the range 0..1.
*/
- getXelA()
C++ Interface: get_xel_a(PNMImage self, int x, int y)
- /**
Returns the RGBA color at the indicated pixel. Each component is a
linearized float in the range 0..1.
*/
- getXelVal()
C++ Interface: get_xel_val(const PNMImage self, int x, int y) get_xel_val(PNMImage self, int x, int y)
- get_alpha()
C++ Interface: get_alpha(PNMImage self, int x, int 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 float in
the range 0..1.
*/
- get_alpha_val()
C++ Interface: get_alpha_val(PNMImage self, int x, int 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 in the
range 0..maxval and always linear.
*/
- get_average_gray()
C++ Interface: get_average_gray(PNMImage self)
- /**
Returns the average grayscale component of all of the pixels in the image.
*/
- get_average_xel()
C++ Interface: get_average_xel(PNMImage self)
- /**
Returns the average color of all of the pixels in the image.
*/
- get_average_xel_a()
C++ Interface: get_average_xel_a(PNMImage self)
- /**
Returns the average color of all of the pixels in the image, including the
alpha channel.
*/
- get_blue()
C++ Interface: get_blue(PNMImage self, int x, int y)
- /**
Returns the blue component color at the indicated pixel. The value
returned is a linearized float in the range 0..1.
*/
- get_blue_val()
C++ Interface: get_blue_val(PNMImage self, int x, int y)
- /**
Returns the blue component color at the indicated pixel. The value
returned is in the range 0..maxval and encoded in the configured color
space.
*/
- get_bright()
C++ Interface: get_bright(PNMImage self, int x, int y) get_bright(PNMImage self, int x, int y, float rc, float gc, float bc) get_bright(PNMImage self, int x, int y, float rc, float gc, float bc, float ac)
- /**
Returns the linear brightness of the given xel, as a linearized float in
the range 0..1. This flavor of get_bright() returns the correct grayscale
brightness level for both full-color and grayscale images.
*/
- /**
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.
*/
- /**
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.
*/
- get_channel()
C++ Interface: get_channel(PNMImage self, int x, int y, int channel)
- /**
Returns the nth component color at the indicated pixel. The channel index
should be in the range 0..(get_num_channels()-1). The channels are ordered
B, G, R, A. This is slightly less optimal than accessing the component
values directly by named methods. The value returned is a float in the
range 0..1.
*/
- get_channel_val()
C++ Interface: get_channel_val(PNMImage self, int x, int y, int channel)
- /**
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.
*/
- get_color_space()
C++ Interface: get_color_space(PNMImage self)
- /**
Returns the color space in which the image is encoded.
*/
- get_gray()
C++ Interface: get_gray(PNMImage self, int x, int y)
- /**
Returns the gray component color at the indicated pixel. This only has a
meaningful value for grayscale images; for other image types, this returns
the value of the blue channel only. However, also see the get_bright()
function. The value returned is a linearized float in the range 0..1.
*/
- get_gray_val()
C++ Interface: get_gray_val(PNMImage self, int x, int y)
- /**
Returns the gray component color at the indicated pixel. This only has a
meaningful value for grayscale images; for other image types, this returns
the value of the blue channel only. However, also see the get_bright()
function. The value returned is in the range 0..maxval and encoded in the
configured color space.
*/
- get_green()
C++ Interface: get_green(PNMImage self, int x, int y)
- /**
Returns the green component color at the indicated pixel. The value
returned is a linearized float in the range 0..1.
*/
- get_green_val()
C++ Interface: get_green_val(PNMImage self, int x, int y)
- /**
Returns the green component color at the indicated pixel. The value
returned is in the range 0..maxval and encoded in the configured color
space.
*/
- get_pixel()
C++ Interface: get_pixel(PNMImage self, int x, int y)
- /**
Returns the (r, g, b, a) pixel value at the indicated pixel, using a
PixelSpec object.
*/
- get_read_x_size()
C++ Interface: get_read_x_size(PNMImage self)
- /**
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).
*/
- get_read_y_size()
C++ Interface: get_read_y_size(PNMImage self)
- /**
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).
*/
- get_red()
C++ Interface: get_red(PNMImage self, int x, int y)
- /**
Returns the red component color at the indicated pixel. The value returned
is a linearized float in the range 0..1.
*/
- get_red_val()
C++ Interface: get_red_val(PNMImage self, int x, int y)
- /**
Returns the red component color at the indicated pixel. The value returned
is in the range 0..maxval and encoded in the configured color space.
*/
- get_xel()
C++ Interface: get_xel(PNMImage self, int x, int y)
- /**
Returns the RGB color at the indicated pixel. Each component is a
linearized float in the range 0..1.
*/
- get_xel_a()
C++ Interface: get_xel_a(PNMImage self, int x, int y)
- /**
Returns the RGBA color at the indicated pixel. Each component is a
linearized float in the range 0..1.
*/
- get_xel_val()
C++ Interface: get_xel_val(const PNMImage self, int x, int y) get_xel_val(PNMImage self, int x, int y)
- hasReadSize()
C++ Interface: has_read_size(PNMImage self)
- /**
Returns true if set_read_size() has been called.
*/
- has_read_size()
C++ Interface: has_read_size(PNMImage self)
- /**
Returns true if set_read_size() has been called.
*/
- indirect1dLookup()
C++ Interface: indirect_1d_lookup(const PNMImage self, const PNMImage index_image, int channel, const PNMImage pixel_values)
- /**
index_image is a WxH grayscale image, while pixel_values is an Nx1 color
(or grayscale) image. Typically pixel_values will be a 256x1 image.
Fills the PNMImage with a new image the same width and height as
index_image, with the same number of channels as pixel_values.
Each pixel of the new image is computed with the formula:
new_image(x, y) = pixel_values(index_image(x, y)[channel], 0)
At present, no interpolation is performed; the nearest value in
pixel_values is discovered. This may change in the future.
*/
- indirect_1d_lookup()
C++ Interface: indirect_1d_lookup(const PNMImage self, const PNMImage index_image, int channel, const PNMImage pixel_values)
- /**
index_image is a WxH grayscale image, while pixel_values is an Nx1 color
(or grayscale) image. Typically pixel_values will be a 256x1 image.
Fills the PNMImage with a new image the same width and height as
index_image, with the same number of channels as pixel_values.
Each pixel of the new image is computed with the formula:
new_image(x, y) = pixel_values(index_image(x, y)[channel], 0)
At present, no interpolation is performed; the nearest value in
pixel_values is discovered. This may change in the future.
*/
- isValid()
C++ Interface: is_valid(PNMImage self)
- /**
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.
*/
- is_valid()
C++ Interface: is_valid(PNMImage self)
- /**
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.
*/
- lightenSubImage()
C++ Interface: lighten_sub_image(const PNMImage self, const PNMImage copy, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size, float pixel_scale)
- /**
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.
*/
- lighten_sub_image()
C++ Interface: lighten_sub_image(const PNMImage self, const PNMImage copy, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size, float pixel_scale)
- /**
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.
*/
- makeGrayscale()
C++ Interface: make_grayscale(const PNMImage self) make_grayscale(const PNMImage self, float rc, float gc, float bc)
- /**
Converts the image from RGB to grayscale. Any alpha channel, if present,
is left undisturbed.
*/
- /**
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.
*/
- makeHistogram()
C++ Interface: make_histogram(const PNMImage self, Histogram hist)
- /**
Computes a histogram of the colors used in the image.
*/
- makeRgb()
C++ Interface: make_rgb(const PNMImage self)
- /**
Converts the image from grayscale to RGB. Any alpha channel, if present,
is left undisturbed.
*/
- make_grayscale()
C++ Interface: make_grayscale(const PNMImage self) make_grayscale(const PNMImage self, float rc, float gc, float bc)
- /**
Converts the image from RGB to grayscale. Any alpha channel, if present,
is left undisturbed.
*/
- /**
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.
*/
- make_histogram()
C++ Interface: make_histogram(const PNMImage self, Histogram hist)
- /**
Computes a histogram of the colors used in the image.
*/
- make_rgb()
C++ Interface: make_rgb(const PNMImage self)
- /**
Converts the image from grayscale to RGB. Any alpha channel, if present,
is left undisturbed.
*/
- multSubImage()
C++ Interface: mult_sub_image(const PNMImage self, const PNMImage copy, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size, float pixel_scale)
- /**
Behaves like copy_sub_image(), except the copy pixels are multiplied to the
pixels of the destination, after scaling by the specified pixel_scale.
Unlike blend_sub_image(), the alpha channel is not treated specially.
*/
- mult_sub_image()
C++ Interface: mult_sub_image(const PNMImage self, const PNMImage copy, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size, float pixel_scale)
- /**
Behaves like copy_sub_image(), except the copy pixels are multiplied to the
pixels of the destination, after scaling by the specified pixel_scale.
Unlike blend_sub_image(), the alpha channel is not treated specially.
*/
- perlinNoiseFill()
C++ Interface: perlin_noise_fill(const PNMImage self, StackedPerlinNoise2 perlin) perlin_noise_fill(const PNMImage self, float sx, float sy, int table_size, int seed, float ox, float oy)
- /**
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.
*/
- /**
Variant of perlin_noise_fill that uses an existing StackedPerlinNoise2
object.
*/
- perlin_noise_fill()
C++ Interface: perlin_noise_fill(const PNMImage self, StackedPerlinNoise2 perlin) perlin_noise_fill(const PNMImage self, float sx, float sy, int table_size, int seed, float ox, float oy)
- /**
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.
*/
- /**
Variant of perlin_noise_fill that uses an existing StackedPerlinNoise2
object.
*/
- premultiplyAlpha()
C++ Interface: premultiply_alpha(const PNMImage self)
- /**
Converts an image in-place to its “premultiplied” form, where, for every
pixel in the image, the red, green, and blue components are multiplied by
that pixel’s alpha value.
This does not modify any alpha values.
*/
- premultiply_alpha()
C++ Interface: premultiply_alpha(const PNMImage self)
- /**
Converts an image in-place to its “premultiplied” form, where, for every
pixel in the image, the red, green, and blue components are multiplied by
that pixel’s alpha value.
This does not modify any alpha values.
*/
- quantize()
C++ Interface: quantize(const PNMImage self, int max_colors)
- /**
Reduces the number of unique colors in the image to (at most) the given
count. Fewer colors than requested may be left in the image after this
operation, but never more.
At present, this is only supported on images without an alpha channel.
@since 1.10.5
*/
- quickFilterFrom()
C++ Interface: quick_filter_from(const PNMImage self, const PNMImage copy, int xborder, int yborder)
- /**
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.
*/
- quick_filter_from()
C++ Interface: quick_filter_from(const PNMImage self, const PNMImage copy, int xborder, int yborder)
- /**
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.
*/
- read()
C++ Interface: read(const PNMImage self, istream data, str filename, PNMFileType type, bool report_unknown_type)
- /**
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.
*/
- /**
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.
*/
- /**
This flavor of read() uses an already-existing PNMReader to read the image
file. You can get a reader via the PNMImageHeader::make_reader() methods.
This is a good way to examine the header of a file (for instance, to
determine its size) before actually reading the entire image.
The PNMReader is always deleted upon completion, whether successful or not.
*/
- remixChannels()
C++ Interface: remix_channels(const PNMImage self, const LMatrix4f conv)
- /**
Transforms every pixel using the operation (Ro,Go,Bo) =
conv.xform_point(Ri,Gi,Bi); Input must be a color image.
*/
- remix_channels()
C++ Interface: remix_channels(const PNMImage self, const LMatrix4f conv)
- /**
Transforms every pixel using the operation (Ro,Go,Bo) =
conv.xform_point(Ri,Gi,Bi); Input must be a color image.
*/
- removeAlpha()
C++ Interface: remove_alpha(const PNMImage self)
- /**
Removes the image’s alpha channel, if it exists.
*/
- remove_alpha()
C++ Interface: remove_alpha(const PNMImage self)
- /**
Removes the image’s alpha channel, if it exists.
*/
- renderSpot()
C++ Interface: render_spot(const PNMImage self, const LVecBase4f fg, const LVecBase4f bg, float min_radius, float max_radius)
- /**
Renders a solid-color circle, with a fuzzy edge, into the center of the
PNMImage. If the PNMImage is non-square, this actually renders an ellipse.
The min_radius and max_radius are in the scale 0..1, where 1.0 means the
full width of the image. If min_radius == max_radius, the edge is sharp
(but still antialiased); otherwise, the pixels between min_radius and
max_radius are smoothly blended between fg and bg colors.
*/
- render_spot()
C++ Interface: render_spot(const PNMImage self, const LVecBase4f fg, const LVecBase4f bg, float min_radius, float max_radius)
- /**
Renders a solid-color circle, with a fuzzy edge, into the center of the
PNMImage. If the PNMImage is non-square, this actually renders an ellipse.
The min_radius and max_radius are in the scale 0..1, where 1.0 means the
full width of the image. If min_radius == max_radius, the edge is sharp
(but still antialiased); otherwise, the pixels between min_radius and
max_radius are smoothly blended between fg and bg colors.
*/
- rescale()
C++ Interface: rescale(const PNMImage self, float min_val, float max_val)
- /**
Rescales the RGB channel values so that any values in the original image
between min_val and max_val are expanded to the range 0 .. 1. Values below
min_val are set to 0, and values above max_val are set to 1. Does not
affect the alpha channel, if any.
*/
- reverseRows()
C++ Interface: reverse_rows(const PNMImage self)
- /**
Performs an in-place reversal of the row (y) data.
*/
- reverse_rows()
C++ Interface: reverse_rows(const PNMImage self)
- /**
Performs an in-place reversal of the row (y) data.
*/
- setAlpha()
C++ Interface: set_alpha(const PNMImage self, int x, int y, float a)
- /**
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.
*/
- setAlphaVal()
C++ Interface: set_alpha_val(const PNMImage self, int x, int y, int a)
- /**
Sets the alpha component color only at the indicated pixel. It is an error
to call this unless has_alpha() is true. The value given should be in the
range 0..maxval.
This value is always linearly encoded, even if the image is set to the sRGB
color space.
*/
- setBlue()
C++ Interface: set_blue(const PNMImage self, int x, int y, float b)
- /**
Sets the blue component color only at the indicated pixel. The value given
should be a linearized float in the range 0..1.
*/
- setBlueVal()
C++ Interface: set_blue_val(const PNMImage self, int x, int y, int b)
- /**
Sets the blue component color only at the indicated pixel. The value given
should be in the range 0..maxval, encoded in the configured color space.
See set_blue if you instead have a linearized and normalized floating-point
value.
*/
- setChannel()
C++ Interface: set_channel(const PNMImage self, int x, int y, int channel, float value)
- /**
Sets the nth component color at the indicated pixel. The channel index
should be in the range 0..(get_num_channels()-1). The channels are ordered
B, G, R, A. This is slightly less optimal than setting the component
values directly by named methods. The value given should be a float in the
range 0..1.
*/
- setChannelVal()
C++ Interface: set_channel_val(const PNMImage self, int x, int y, int channel, int 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.
*/
- setColorSpace()
C++ Interface: set_color_space(const PNMImage self, int color_space)
- /**
Converts the colors in the image to the indicated color space. This may be
a lossy operation, in particular when going from sRGB to linear. The alpha
channel remains untouched.
Note that, because functions like get_xel() and set_xel() work on
linearized floating-point values, this conversion won’t affect those values
(aside from some minor discrepancies due to storage precision). It does
affect the values used by get_xel_val() and set_xel_val(), though, since
those operate on encoded colors.
Some color spaces, particularly scRGB, may enforce the use of a particular
maxval setting.
*/
- setColorType()
C++ Interface: set_color_type(const PNMImage self, int 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.
*/
- setGray()
C++ Interface: set_gray(const PNMImage self, int x, int y, float gray)
- /**
Sets the gray component color at the indicated pixel. This is only
meaningful for grayscale images; for other image types, this simply sets
the blue component color. However, also see set_xel(), which can set all
the component colors to the same grayscale level, and hence works correctly
both for grayscale and color images. The value given should be a
linearized float in the range 0..1.
*/
- setGrayVal()
C++ Interface: set_gray_val(const PNMImage self, int x, int y, int gray)
- /**
Sets the gray component color at the indicated pixel. This is only
meaningful for grayscale images; for other image types, this simply sets
the blue component color. However, also see set_xel_val(), which can set
all the component colors to the same grayscale level, and hence works
correctly both for grayscale and color images. The value given should be
in the range 0..maxval, encoded in the configured color space. See
set_gray if you instead have a linearized normalized floating-point value.
*/
- setGreen()
C++ Interface: set_green(const PNMImage self, int x, int y, float g)
- /**
Sets the green component color only at the indicated pixel. The value
given should be a linearized float in the range 0..1.
*/
- setGreenVal()
C++ Interface: set_green_val(const PNMImage self, int x, int y, int g)
- /**
Sets the green component color only at the indicated pixel. The value
given should be in the range 0..maxval, encoded in the configured color
space. See set_green if you instead have a linearized and normalized
floating-point value.
*/
- setMaxval()
C++ Interface: set_maxval(const PNMImage self, int maxval)
- /**
Rescales the image to the indicated maxval.
*/
- setNumChannels()
C++ Interface: set_num_channels(const PNMImage self, int num_channels)
- /**
Changes the number of channels associated with the image. The new number
of channels must be an integer in the range 1 through 4, inclusive. This
will allocate and/or deallocate memory as necessary to accommodate; see
set_color_type().
*/
- setPixel()
C++ Interface: set_pixel(const PNMImage self, int x, int y, const PixelSpec pixel)
- /**
Sets the (r, g, b, a) pixel value at the indicated pixel, using a PixelSpec
object.
*/
- setReadSize()
C++ Interface: set_read_size(const PNMImage self, int x_size, int y_size)
- /**
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.
*/
- setRed()
C++ Interface: set_red(const PNMImage self, int x, int y, float r)
- /**
Sets the red component color only at the indicated pixel. The value given
should be a linearized float in the range 0..1.
*/
- setRedVal()
C++ Interface: set_red_val(const PNMImage self, int x, int y, int r)
- /**
Sets the red component color only at the indicated pixel. The value given
should be in the range 0..maxval, encoded in the configured color space.
See set_red if you instead have a linearized and normalized floating-point
value.
*/
- setXel()
C++ Interface: set_xel(const PNMImage self, int x, int y, const LVecBase3f value) set_xel(const PNMImage self, int x, int y, float gray) set_xel(const PNMImage self, int x, int y, float r, float g, float b)
- /**
Changes the RGB color at the indicated pixel. Each component is a
linearized float in the range 0..1.
*/
- /**
Changes the RGB color at the indicated pixel. Each component is a
linearized float in the range 0..1.
*/
- /**
Changes all three color components at the indicated pixel to the same
value. The value is a linearized float in the range 0..1.
*/
- setXelA()
C++ Interface: set_xel_a(const PNMImage self, int x, int y, const LVecBase4f value) set_xel_a(const PNMImage self, int x, int y, float r, float g, float b, float a)
- setXelVal()
C++ Interface: set_xel_val(const PNMImage self, int x, int y, const pixel value) set_xel_val(const PNMImage self, int x, int y, int gray) set_xel_val(const PNMImage self, int x, int y, int r, int g, int b)
- /**
Changes the RGB color at the indicated pixel. Each component is in the
range 0..maxval, encoded in the configured color space. See set_xel if you
instead have a linearized and normalized floating-point value.
*/
- /**
Changes the RGB color at the indicated pixel. Each component is in the
range 0..maxval, encoded in the configured color space. See set_xel if you
instead have a linearized and normalized floating-point value.
*/
- /**
Changes all three color components at the indicated pixel to the same
value. The value is in the range component is in the range 0..maxval,
encoded in the configured color space. See set_xel if you instead have a
linearized and normalized floating-point value.
*/
- set_alpha()
C++ Interface: set_alpha(const PNMImage self, int x, int y, float a)
- /**
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.
*/
- set_alpha_val()
C++ Interface: set_alpha_val(const PNMImage self, int x, int y, int a)
- /**
Sets the alpha component color only at the indicated pixel. It is an error
to call this unless has_alpha() is true. The value given should be in the
range 0..maxval.
This value is always linearly encoded, even if the image is set to the sRGB
color space.
*/
- set_blue()
C++ Interface: set_blue(const PNMImage self, int x, int y, float b)
- /**
Sets the blue component color only at the indicated pixel. The value given
should be a linearized float in the range 0..1.
*/
- set_blue_val()
C++ Interface: set_blue_val(const PNMImage self, int x, int y, int b)
- /**
Sets the blue component color only at the indicated pixel. The value given
should be in the range 0..maxval, encoded in the configured color space.
See set_blue if you instead have a linearized and normalized floating-point
value.
*/
- set_channel()
C++ Interface: set_channel(const PNMImage self, int x, int y, int channel, float value)
- /**
Sets the nth component color at the indicated pixel. The channel index
should be in the range 0..(get_num_channels()-1). The channels are ordered
B, G, R, A. This is slightly less optimal than setting the component
values directly by named methods. The value given should be a float in the
range 0..1.
*/
- set_channel_val()
C++ Interface: set_channel_val(const PNMImage self, int x, int y, int channel, int 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.
*/
- set_color_space()
C++ Interface: set_color_space(const PNMImage self, int color_space)
- /**
Converts the colors in the image to the indicated color space. This may be
a lossy operation, in particular when going from sRGB to linear. The alpha
channel remains untouched.
Note that, because functions like get_xel() and set_xel() work on
linearized floating-point values, this conversion won’t affect those values
(aside from some minor discrepancies due to storage precision). It does
affect the values used by get_xel_val() and set_xel_val(), though, since
those operate on encoded colors.
Some color spaces, particularly scRGB, may enforce the use of a particular
maxval setting.
*/
- set_color_type()
C++ Interface: set_color_type(const PNMImage self, int 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.
*/
- set_gray()
C++ Interface: set_gray(const PNMImage self, int x, int y, float gray)
- /**
Sets the gray component color at the indicated pixel. This is only
meaningful for grayscale images; for other image types, this simply sets
the blue component color. However, also see set_xel(), which can set all
the component colors to the same grayscale level, and hence works correctly
both for grayscale and color images. The value given should be a
linearized float in the range 0..1.
*/
- set_gray_val()
C++ Interface: set_gray_val(const PNMImage self, int x, int y, int gray)
- /**
Sets the gray component color at the indicated pixel. This is only
meaningful for grayscale images; for other image types, this simply sets
the blue component color. However, also see set_xel_val(), which can set
all the component colors to the same grayscale level, and hence works
correctly both for grayscale and color images. The value given should be
in the range 0..maxval, encoded in the configured color space. See
set_gray if you instead have a linearized normalized floating-point value.
*/
- set_green()
C++ Interface: set_green(const PNMImage self, int x, int y, float g)
- /**
Sets the green component color only at the indicated pixel. The value
given should be a linearized float in the range 0..1.
*/
- set_green_val()
C++ Interface: set_green_val(const PNMImage self, int x, int y, int g)
- /**
Sets the green component color only at the indicated pixel. The value
given should be in the range 0..maxval, encoded in the configured color
space. See set_green if you instead have a linearized and normalized
floating-point value.
*/
- set_maxval()
C++ Interface: set_maxval(const PNMImage self, int maxval)
- /**
Rescales the image to the indicated maxval.
*/
- set_num_channels()
C++ Interface: set_num_channels(const PNMImage self, int num_channels)
- /**
Changes the number of channels associated with the image. The new number
of channels must be an integer in the range 1 through 4, inclusive. This
will allocate and/or deallocate memory as necessary to accommodate; see
set_color_type().
*/
- set_pixel()
C++ Interface: set_pixel(const PNMImage self, int x, int y, const PixelSpec pixel)
- /**
Sets the (r, g, b, a) pixel value at the indicated pixel, using a PixelSpec
object.
*/
- set_read_size()
C++ Interface: set_read_size(const PNMImage self, int x_size, int y_size)
- /**
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.
*/
- set_red()
C++ Interface: set_red(const PNMImage self, int x, int y, float r)
- /**
Sets the red component color only at the indicated pixel. The value given
should be a linearized float in the range 0..1.
*/
- set_red_val()
C++ Interface: set_red_val(const PNMImage self, int x, int y, int r)
- /**
Sets the red component color only at the indicated pixel. The value given
should be in the range 0..maxval, encoded in the configured color space.
See set_red if you instead have a linearized and normalized floating-point
value.
*/
- set_xel()
C++ Interface: set_xel(const PNMImage self, int x, int y, const LVecBase3f value) set_xel(const PNMImage self, int x, int y, float gray) set_xel(const PNMImage self, int x, int y, float r, float g, float b)
- /**
Changes the RGB color at the indicated pixel. Each component is a
linearized float in the range 0..1.
*/
- /**
Changes the RGB color at the indicated pixel. Each component is a
linearized float in the range 0..1.
*/
- /**
Changes all three color components at the indicated pixel to the same
value. The value is a linearized float in the range 0..1.
*/
- set_xel_a()
C++ Interface: set_xel_a(const PNMImage self, int x, int y, const LVecBase4f value) set_xel_a(const PNMImage self, int x, int y, float r, float g, float b, float a)
- set_xel_val()
C++ Interface: set_xel_val(const PNMImage self, int x, int y, const pixel value) set_xel_val(const PNMImage self, int x, int y, int gray) set_xel_val(const PNMImage self, int x, int y, int r, int g, int b)
- /**
Changes the RGB color at the indicated pixel. Each component is in the
range 0..maxval, encoded in the configured color space. See set_xel if you
instead have a linearized and normalized floating-point value.
*/
- /**
Changes the RGB color at the indicated pixel. Each component is in the
range 0..maxval, encoded in the configured color space. See set_xel if you
instead have a linearized and normalized floating-point value.
*/
- /**
Changes all three color components at the indicated pixel to the same
value. The value is in the range component is in the range 0..maxval,
encoded in the configured color space. See set_xel if you instead have a
linearized and normalized floating-point value.
*/
- takeFrom()
C++ Interface: take_from(const PNMImage self, PNMImage orig)
- /**
Move the contents of the other image into this one, and empty the other
image.
*/
- take_from()
C++ Interface: take_from(const PNMImage self, PNMImage orig)
- /**
Move the contents of the other image into this one, and empty the other
image.
*/
- threshold()
C++ Interface: threshold(const PNMImage self, const PNMImage select_image, int channel, float threshold, const PNMImage lt, const PNMImage ge)
- /**
Selectively copies each pixel from either one source or another source,
depending on the pixel value of the indicated channel of select_image.
For each pixel (x, y):
s = select_image.get_channel(x, y, channel). Set this image’s (x, y) to:
lt.get_xel(x, y) if s < threshold, or
ge.get_xel(x, y) if s >= threshold
Any of select_image, lt, or ge may be the same PNMImge object as this
image, or the same as each other; or they may all be different. All images
must be the same size. As a special case, lt and ge may both be 1x1 images
instead of the source image size.
*/
- toAlphaVal()
C++ Interface: to_alpha_val(PNMImage self, float input_value)
- /**
A handy function to scale alpha values from [0..1] to [0..get_maxval()].
*/
- toVal()
C++ Interface: to_val(PNMImage self, const LVecBase3f input_value) to_val(PNMImage self, float input_value)
- to_alpha_val()
C++ Interface: to_alpha_val(PNMImage self, float input_value)
- /**
A handy function to scale alpha values from [0..1] to [0..get_maxval()].
*/
- to_val()
C++ Interface: to_val(PNMImage self, const LVecBase3f input_value) to_val(PNMImage self, float input_value)
- unfilteredStretchFrom()
C++ Interface: unfiltered_stretch_from(const PNMImage self, const PNMImage copy)
- /**
Resizes from the indicated image into this one by performing a nearest-
point sample.
*/
- unfiltered_stretch_from()
C++ Interface: unfiltered_stretch_from(const PNMImage self, const PNMImage copy)
- /**
Resizes from the indicated image into this one by performing a nearest-
point sample.
*/
- unpremultiplyAlpha()
C++ Interface: unpremultiply_alpha(const PNMImage self)
- /**
Converts an image in-place to its “straight alpha” form (presumably from a
“premultiplied” form), where, for every pixel in the image, the red, green,
and blue components are divided by that pixel’s alpha value.
This does not modify any alpha values.
*/
- unpremultiply_alpha()
C++ Interface: unpremultiply_alpha(const PNMImage self)
- /**
Converts an image in-place to its “straight alpha” form (presumably from a
“premultiplied” form), where, for every pixel in the image, the red, green,
and blue components are divided by that pixel’s alpha value.
This does not modify any alpha values.
*/
- write()
C++ Interface: write(PNMImage self, ostream data, str filename, PNMFileType type)
- /**
Writes the image to the indicated filename. If type is non-NULL, it is a
suggestion for the type of image file to write.
*/
- /**
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.
*/
- /**
This flavor of write() uses an already-existing PNMWriter to write the
image file. You can get a writer via the PNMImageHeader::make_writer()
methods.
The PNMWriter is always deleted upon completion, whether successful or not.
*/