#include <pnmImageHeader.h>
Inheritance diagram for PNMImageHeader:
Public Types | |
enum | ColorType { CT_invalid = 0, CT_grayscale = 1, CT_two_channel = 2, CT_color = 3, CT_four_channel = 4 } |
Public Member Functions | |
PNMImageHeader () | |
PNMImageHeader (const PNMImageHeader ©) | |
void | operator= (const PNMImageHeader ©) |
~PNMImageHeader () | |
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 |
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.
Definition at line 55 of file pnmImageHeader.h.
|
Definition at line 65 of file pnmImageHeader.h. |
|
Definition at line 30 of file pnmImageHeader.I. |
|
Definition at line 46 of file pnmImageHeader.I. |
|
Definition at line 79 of file pnmImageHeader.I. References _num_channels, CT_invalid, and nassertr. |
|
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 CT_grayscale, CT_two_channel, and INLINE. Referenced by get_num_channels(), PNMImage::write(), and PixelBuffer::write(). |
|
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 _type. Referenced by PNMImage::clamp_val(), PNMImage::fill(), PNMImage::operator=(), and PNMImage::~PNMImage(). |
|
Returns the number of channels in the image.
Definition at line 109 of file pnmImageHeader.I. References get_color_type(), INLINE, and is_grayscale(). Referenced by PixelBuffer::write(). |
|
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 PNMImage::copy_header_from(), down_to_power_2(), Texture::read(), WindowFramework::set_background_type(), PNMImage::set_color_type(), and PNMImage::write(). |
|
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 PNMImage::copy_header_from(), down_to_power_2(), Texture::read(), WindowFramework::set_background_type(), PNMImage::set_color_type(), and PNMImage::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 _type, INLINE, and NULL. Referenced by PNMImage::copy_from(), PNMImage::set_color_type(), and PNMImage::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 _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 _maxval, INLINE, and xelval. Referenced by get_num_channels(), PNMImage::set_color_type(), PNMImage::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 CT_four_channel, CT_two_channel, and INLINE. Referenced by filter_image(). |
|
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 _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. |
|
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 _type, Filename::empty(), PNMFileType::get_name(), PNMFileTypeRegistry::get_ptr(), PNMFileTypeRegistry::get_type_from_extension(), PNMFileType::make_writer(), NULL, and writer(). |
|
Definition at line 63 of file pnmImageHeader.I. References INLINE. Referenced by PNMImage::copy_from(), and PNMWriter::set_x_size(). |
|
Definition at line 474 of file pnmImageHeader.cxx. |
|
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. |
|
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. |
|
|
Definition at line 113 of file pnmImageHeader.h. Referenced by PNMImage::make_grayscale(), PNMWriter::set_color_type(), PNMImage::set_maxval(), PNMFileTypeSGI::Writer::write_channels(), PNMFileTypeSGI::Writer::write_rgb_header(), PNMFileTypeSGI::Writer::write_table(), and ~PNMImageHeader(). |
|
Reimplemented in PNMReader, and PNMWriter. Definition at line 115 of file pnmImageHeader.h. Referenced by get_maxval(), has_alpha(), make_reader(), make_writer(), and PNMImageHeader(). |
|
|