#include <pnmReader.h>
Inheritance diagram for PNMReader:
Public Types | |
enum | ColorType { CT_invalid = 0, CT_grayscale = 1, CT_two_channel = 2, CT_color = 3, CT_four_channel = 4 } |
Public Member Functions | |
virtual | ~PNMReader () |
PNMFileType * | get_type () const |
Returns a pointer to the PNMFileType object that created this PNMReader. | |
virtual int | read_data (xel *array, xelval *alpha) |
Reads in an entire image all at once, storing it in the pre-allocated _x_size * _y_size array and alpha pointers. | |
virtual bool | supports_read_row () const |
Returns true if this particular PNMReader is capable of returning the data one row at a time, via repeated calls to read_row(). | |
virtual bool | read_row (xel *array, xelval *alpha) |
If supports_read_row(), above, returns true, this function may be called repeatedly to read the image, one horizontal row at a time, beginning from the top. | |
virtual bool | supports_stream_read () const |
Returns true if this particular PNMReader can read from a general stream (including pipes, etc.), or false if the reader must occasionally fseek() on its input stream, and thus only disk streams are supported. | |
bool | is_valid () const |
Returns true if the PNMReader can be used to read data, false if something is wrong. | |
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. | |
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 Member Functions | |
PNMReader (PNMFileType *type, istream *file, bool owns_file) | |
Protected Attributes | |
PNMFileType * | _type |
bool | _owns_file |
istream * | _file |
bool | _is_valid |
int | _x_size |
int | _y_size |
int | _num_channels |
xelval | _maxval |
Any particular image file type that can be read must define a class that inherits from PNMReader to read it.
Definition at line 45 of file pnmReader.h.
|
Definition at line 65 of file pnmImageHeader.h. |
|
Definition at line 30 of file pnmReader.I. |
|
Definition at line 32 of file pnmReader.cxx. |
|
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(), 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 PNMImageHeader::_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 PNMImageHeader::get_color_type(), INLINE, and PNMImageHeader::is_grayscale(). Referenced by PixelBuffer::write(). |
|
Returns a pointer to the PNMFileType object that created this PNMReader.
Reimplemented from PNMImageHeader. Definition at line 49 of file pnmReader.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 PNMImageHeader::_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 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(), 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 PNMImageHeader::CT_four_channel, PNMImageHeader::CT_two_channel, and INLINE. Referenced by filter_image(). |
|
Returns true if the PNMReader can be used to read data, false if something is wrong.
Definition at line 64 of file pnmReader.I. |
|
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. |
|
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 474 of file pnmImageHeader.cxx. |
|
Reads in an entire image all at once, storing it in the pre-allocated _x_size * _y_size array and alpha pointers. (If the image type has no alpha channel, alpha is ignored.) Returns the number of rows correctly read. Derived classes need not override this if they instead provide supports_read_row() and read_row(), below. Reimplemented in PNMFileTypeBMP::Reader, PNMFileTypeJPG::Reader, PNMFileTypeJPG2000::Reader, and PNMFileTypeTGA::Reader. Definition at line 64 of file pnmReader.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. |
|
If supports_read_row(), above, returns true, this function may be called repeatedly to read the image, one horizontal row at a time, beginning from the top. Returns true if the row is successfully read, false if there is an error or end of file. Reimplemented in PNMFileTypeAlias::Reader, PNMFileTypeIMG::Reader, PNMFileTypeSGI::Reader, PNMFileTypeSoftImage::Reader, and PNMFileTypeTIFF::Reader. Definition at line 118 of file pnmReader.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. |
|
Returns true if this particular PNMReader is capable of returning the data one row at a time, via repeated calls to read_row(). Returns false if the only way to read from this file is all at once, via read_data(). Reimplemented in PNMFileTypeAlias::Reader, PNMFileTypeIMG::Reader, PNMFileTypeSGI::Reader, PNMFileTypeSoftImage::Reader, and PNMFileTypeTIFF::Reader. Definition at line 97 of file pnmReader.cxx. |
|
Returns true if this particular PNMReader can read from a general stream (including pipes, etc.), or false if the reader must occasionally fseek() on its input stream, and thus only disk streams are supported.
Definition at line 140 of file pnmReader.cxx. |
|
Definition at line 65 of file pnmReader.h. Referenced by PNMFileTypeIMG::Reader::read_row(). |
|
Reimplemented in PNMFileTypeJPG::Reader. Definition at line 66 of file pnmReader.h. Referenced by get_type(). |
|
|
|
Definition at line 64 of file pnmReader.h. |
|
Reimplemented from PNMImageHeader. Definition at line 63 of file pnmReader.h. |
|
|