PNMImageHeader

from panda3d.core import PNMImageHeader
class PNMImageHeader

Bases: DTOOL_SUPER_BASE

This is the base class of PNMImage, PNMReader, and PNMWriter. It encapsulates all the information associated with an image that describes its size, number of channels, etc; that is, all the information about the image except the image data itself. It’s the sort of information you typically read from the image file’s header.

Inheritance diagram

Inheritance diagram of PNMImageHeader

CTColor = 3
CTFourChannel = 4
CTGrayscale = 1
CTInvalid = 0
CTTwoChannel = 2
CT_color = 3
CT_four_channel = 4
CT_grayscale = 1
CT_invalid = 0
CT_two_channel = 2
class Histogram

Bases: DTOOL_SUPER_BASE

Used to return a pixel histogram in PNMImage::get_histogram().

__init__(*args, **kwargs)
getCount()

C++ Interface: get_count(Histogram self, const PixelSpec pixel) get_count(Histogram self, int n)

/**
  • Returns the number of occurrences in the image of the nth unique pixel

  • color in the histogram.

*/

/**
  • Returns the number of occurrences in the image of the indicated pixel

  • color.

*/

getNumPixels()

C++ Interface: get_num_pixels(Histogram self)

/**
  • Returns the number of unique pixel colors in the histogram.

*/

getPixel()

C++ Interface: get_pixel(Histogram self, int n)

/**
  • Returns the nth unique pixel color in the histogram. These are ordered by

  • default from most common to least common.

*/

getPixels()
get_count()

C++ Interface: get_count(Histogram self, const PixelSpec pixel) get_count(Histogram self, int n)

/**
  • Returns the number of occurrences in the image of the nth unique pixel

  • color in the histogram.

*/

/**
  • Returns the number of occurrences in the image of the indicated pixel

  • color.

*/

get_num_pixels()

C++ Interface: get_num_pixels(Histogram self)

/**
  • Returns the number of unique pixel colors in the histogram.

*/

get_pixel()

C++ Interface: get_pixel(Histogram self, int n)

/**
  • Returns the nth unique pixel color in the histogram. These are ordered by

  • default from most common to least common.

*/

get_pixels()
write()

C++ Interface: write(Histogram self, ostream out)

/**

*/

class PixelSpec

Bases: DTOOL_SUPER_BASE

Contains a single pixel specification used in compute_histogram() and make_histogram(). Note that pixels are stored by integer value, not by floating-point scaled value.

__init__(*args, **kwargs)
compareTo()

C++ Interface: compare_to(PixelSpec self, const PixelSpec other)

/**

*/

compare_to()

C++ Interface: compare_to(PixelSpec self, const PixelSpec other)

/**

*/

getAlpha()

C++ Interface: get_alpha(PixelSpec self)

/**

*/

getBlue()

C++ Interface: get_blue(PixelSpec self)

/**

*/

getGreen()

C++ Interface: get_green(PixelSpec self)

/**

*/

getRed()

C++ Interface: get_red(PixelSpec self)

/**

*/

get_alpha()

C++ Interface: get_alpha(PixelSpec self)

/**

*/

get_blue()

C++ Interface: get_blue(PixelSpec self)

/**

*/

get_green()

C++ Interface: get_green(PixelSpec self)

/**

*/

get_red()

C++ Interface: get_red(PixelSpec self)

/**

*/

output()

C++ Interface: output(PixelSpec self, ostream out)

/**

*/

setAlpha()

C++ Interface: set_alpha(const PixelSpec self, int alpha)

/**

*/

setBlue()

C++ Interface: set_blue(const PixelSpec self, int blue)

/**

*/

setGreen()

C++ Interface: set_green(const PixelSpec self, int green)

/**

*/

setRed()

C++ Interface: set_red(const PixelSpec self, int red)

/**

*/

set_alpha()

C++ Interface: set_alpha(const PixelSpec self, int alpha)

/**

*/

set_blue()

C++ Interface: set_blue(const PixelSpec self, int blue)

/**

*/

set_green()

C++ Interface: set_green(const PixelSpec self, int green)

/**

*/

set_red()

C++ Interface: set_red(const PixelSpec self, int red)

/**

*/

class PixelSpecCount

Bases: DTOOL_SUPER_BASE

Associates a pixel specification with an appearance count, for use in Histogram, below.

__init__(*args, **kwargs)
__init__(*args, **kwargs)
assign()

C++ Interface: assign(const PNMImageHeader self, const PNMImageHeader copy)

color_space
comment
getColorSpace()

C++ Interface: get_color_space(PNMImageHeader self)

/**
  • Returns the color space that the image is encoded in, or CS_unspecified if

  • unknown.

*/

getColorType()

C++ Interface: get_color_type(PNMImageHeader self)

/**
  • Returns the image type of the image, as an enumerated value. This is

  • really just the number of channels cast to the enumerated type.

*/

getComment()

C++ Interface: get_comment(PNMImageHeader self)

/**
  • Gets the user comment from the file.

*/

getMaxval()

C++ Interface: get_maxval(PNMImageHeader self)

/**
  • 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.

*/

getNumChannels()

C++ Interface: get_num_channels(PNMImageHeader self)

/**
  • Returns the number of channels in the image.

*/

getSize()

C++ Interface: get_size(PNMImageHeader self)

/**
  • Returns the number of pixels in each direction. This is one more than the

  • largest allowable coordinates.

*/

getType()

C++ Interface: get_type(PNMImageHeader self)

/**
  • If the file type is known (e.g. has_type() returns true), returns its

  • PNMFileType pointer; otherwise, returns NULL.

*/

getXSize()

C++ Interface: get_x_size(PNMImageHeader self)

/**
  • Returns the number of pixels in the X direction. This is one more than the

  • largest allowable X coordinate.

*/

getYSize()

C++ Interface: get_y_size(PNMImageHeader self)

/**
  • Returns the number of pixels in the Y direction. This is one more than the

  • largest allowable Y coordinate.

*/

get_color_space()

C++ Interface: get_color_space(PNMImageHeader self)

/**
  • Returns the color space that the image is encoded in, or CS_unspecified if

  • unknown.

*/

get_color_type()

C++ Interface: get_color_type(PNMImageHeader self)

/**
  • Returns the image type of the image, as an enumerated value. This is

  • really just the number of channels cast to the enumerated type.

*/

get_comment()

C++ Interface: get_comment(PNMImageHeader self)

/**
  • Gets the user comment from the file.

*/

get_maxval()

C++ Interface: get_maxval(PNMImageHeader self)

/**
  • 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.

*/

get_num_channels()

C++ Interface: get_num_channels(PNMImageHeader self)

/**
  • Returns the number of channels in the image.

*/

get_size()

C++ Interface: get_size(PNMImageHeader self)

/**
  • Returns the number of pixels in each direction. This is one more than the

  • largest allowable coordinates.

*/

get_type()

C++ Interface: get_type(PNMImageHeader self)

/**
  • If the file type is known (e.g. has_type() returns true), returns its

  • PNMFileType pointer; otherwise, returns NULL.

*/

get_x_size()

C++ Interface: get_x_size(PNMImageHeader self)

/**
  • Returns the number of pixels in the X direction. This is one more than the

  • largest allowable X coordinate.

*/

get_y_size()

C++ Interface: get_y_size(PNMImageHeader self)

/**
  • Returns the number of pixels in the Y direction. This is one more than the

  • largest allowable Y coordinate.

*/

hasAlpha()

C++ Interface: has_alpha(PNMImageHeader self) has_alpha(int color_type)

/**
  • This static variant of has_alpha() returns true if the indicated image type

  • includes an alpha channel, false otherwise.

*/

/**
  • 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.

*/

hasType()

C++ Interface: has_type(PNMImageHeader self)

/**
  • Returns true if the PNMImageHeader knows what type it is, false otherwise.

*/

has_alpha()

C++ Interface: has_alpha(PNMImageHeader self) has_alpha(int color_type)

/**
  • This static variant of has_alpha() returns true if the indicated image type

  • includes an alpha channel, false otherwise.

*/

/**
  • 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.

*/

has_type()

C++ Interface: has_type(PNMImageHeader self)

/**
  • Returns true if the PNMImageHeader knows what type it is, false otherwise.

*/

isGrayscale()

C++ Interface: is_grayscale(PNMImageHeader self) is_grayscale(int color_type)

/**
  • This static variant of is_grayscale() returns true if the indicated image

  • type represents a grayscale image, false otherwise.

*/

/**
  • 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.)

*/

is_grayscale()

C++ Interface: is_grayscale(PNMImageHeader self) is_grayscale(int color_type)

/**
  • This static variant of is_grayscale() returns true if the indicated image

  • type represents a grayscale image, false otherwise.

*/

/**
  • 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.)

*/

maxval
num_channels
output()

C++ Interface: output(PNMImageHeader self, ostream out)

/**

*/

readHeader()

C++ Interface: read_header(const PNMImageHeader self, istream data, str filename, PNMFileType type, bool report_unknown_type)

/**
  • 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.

*/

/**
  • Reads the image header information only from the indicated stream.

  • The filename is advisory only, and may be used to suggest a type if it has

  • a known extension.

  • If type is non-NULL, it is a suggestion for the type of file it is (and a

  • non-NULL type will override any magic number test or filename extension

  • lookup).

  • Returns true if successful, false on error.

*/

read_header()

C++ Interface: read_header(const PNMImageHeader self, istream data, str filename, PNMFileType type, bool report_unknown_type)

/**
  • 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.

*/

/**
  • Reads the image header information only from the indicated stream.

  • The filename is advisory only, and may be used to suggest a type if it has

  • a known extension.

  • If type is non-NULL, it is a suggestion for the type of file it is (and a

  • non-NULL type will override any magic number test or filename extension

  • lookup).

  • Returns true if successful, false on error.

*/

setComment()

C++ Interface: set_comment(const PNMImageHeader self, str comment)

/**
  • Writes a user comment string to the image (header).

*/

setType()

C++ Interface: set_type(const PNMImageHeader self, PNMFileType type)

/**
  • 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.

*/

set_comment()

C++ Interface: set_comment(const PNMImageHeader self, str comment)

/**
  • Writes a user comment string to the image (header).

*/

set_type()

C++ Interface: set_type(const PNMImageHeader self, PNMFileType type)

/**
  • 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.

*/

size
type