Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

ImageFile Class Reference

This is the base class of both TextureImage and PaletteImage. More...

#include <imageFile.h>

Inheritance diagram for ImageFile:

TypedWritable TypedObject DestTextureImage PaletteImage SourceTextureImage TextureImage List of all members.

Public Member Functions

 ImageFile ()
void make_shadow_image (const string &basename)
 Sets up the ImageFile as a "shadow image" of a particular PaletteImage.

bool is_size_known () const
 Returns true if the size of the image file is known, false otherwise.

int get_x_size () const
 Returns the size of the image file in pixels in the X direction.

int get_y_size () const
 Returns the size of the image file in pixels in the Y direction.

bool has_num_channels () const
 Returns true if the number of channels in the image is known, false otherwise.

int get_num_channels () const
 Returns the number of channels of the image.

const TexturePropertiesget_properties () const
 Returns the grouping properties of the image.

void clear_basic_properties ()
 Resets the properties to a neutral state, for instance in preparation for calling update_properties() with all the known contributing properties.

void update_properties (const TextureProperties &properties)
 If the indicate TextureProperties structure is more specific than this one, updates this one.

void set_filename (PaletteGroup *group, const string &basename)
 Sets the filename, and if applicable, the alpha_filename, from the indicated basename.

void set_filename (const string &dirname, const string &basename)
 Sets the filename, and if applicable, the alpha_filename, from the indicated basename.

const Filenameget_filename () const
 Returns the primary filename of the image file.

const Filenameget_alpha_filename () const
 Returns the alpha filename of the image file.

int get_alpha_file_channel () const
 Returns the particular channel number of the alpha image file from which the alpha channel should be extracted.

bool exists () const
 Returns true if the file or files named by the image file exist, false otherwise.

bool read (PNMImage &image) const
 Reads in the image (or images, if the alpha_filename is separate) and stores it in the indicated PNMImage.

bool write (const PNMImage &image) const
 Writes out the image in the indicated PNMImage to the _filename and/or _alpha_filename.

void unlink ()
 Deletes the image file or files.

void update_egg_tex (EggTexture *egg_tex) const
 Sets the indicated EggTexture to refer to this file.

void output_filename (ostream &out) const
 Writes the filename (or pair of filenames) to the indicated output stream.

virtual void write_datagram (BamWriter *writer, Datagram &datagram)
 Fills the indicated datagram up with a binary representation of the current object, in preparation for writing to a Bam file.

virtual int complete_pointers (TypedWritable **p_list, BamReader *manager)
 Called after the object is otherwise completely read from a Bam file, this function's job is to store the pointers that were retrieved from the Bam file for each pointer object written.

virtual TypeHandle get_type () const
virtual void finalize ()
virtual TypeHandle force_init_type (void)
int get_type_index () const
bool is_of_type (TypeHandle handle) const
bool is_exact_type (TypeHandle handle) const

Static Public Member Functions

TypeHandle get_class_type ()
void init_type ()

Static Public Attributes

TypedWritable *const Null

Protected Member Functions

void fillin (DatagramIterator &scan, BamReader *manager)
 Reads the binary data from the given datagram iterator, which was written by a previous call to write_datagram().


Protected Attributes

TextureProperties _properties
Filename _filename
Filename _alpha_filename
int _alpha_file_channel
bool _size_known
int _x_size
int _y_size

Static Private Attributes

TypeHandle _type_handle

Detailed Description

This is the base class of both TextureImage and PaletteImage.

It encapsulates all the information specific to an image file that can be assigned as a texture image to egg geometry.

Definition at line 49 of file imageFile.h.


Constructor & Destructor Documentation

ImageFile::ImageFile  ) 
 

Definition at line 45 of file imageFile.cxx.


Member Function Documentation

void ImageFile::clear_basic_properties  ) 
 

Resets the properties to a neutral state, for instance in preparation for calling update_properties() with all the known contributing properties.

Definition at line 187 of file imageFile.cxx.

int ImageFile::complete_pointers TypedWritable **  p_list,
BamReader manager
[virtual]
 

Called after the object is otherwise completely read from a Bam file, this function's job is to store the pointers that were retrieved from the Bam file for each pointer object written.

The return value is the number of pointers processed from the list.

Reimplemented from TypedWritable.

Reimplemented in PaletteImage, SourceTextureImage, and TextureImage.

Definition at line 609 of file imageFile.cxx.

Referenced by PaletteImage::find_overlap().

bool ImageFile::exists  )  const
 

Returns true if the file or files named by the image file exist, false otherwise.

Definition at line 361 of file imageFile.cxx.

References _alpha_filename, TextureProperties::_alpha_type, TextureProperties::_color_type, _filename, _properties, Filename::empty(), Filename::exists(), PNMImage::get_maxval(), PNMImage::get_x_size(), PNMImage::get_y_size(), PNMImage::has_alpha(), Filename::make_dir(), FilenameUnifier::make_user_filename(), nassertr, nout, NULL, Filename::unlink(), PNMImage::write(), x, and y.

Referenced by TextureImage::is_used().

void ImageFile::fillin DatagramIterator scan,
BamReader manager
[protected]
 

Reads the binary data from the given datagram iterator, which was written by a previous call to write_datagram().

Reimplemented from TypedWritable.

Reimplemented in DestTextureImage, PaletteImage, SourceTextureImage, and TextureImage.

Definition at line 630 of file imageFile.cxx.

Referenced by SourceTextureImage::write_datagram().

int ImageFile::get_alpha_file_channel  )  const
 

Returns the particular channel number of the alpha image file from which the alpha channel should be extracted.

This is normally 0 to represent the grayscale combination of r, g, and b; or it may be a 1-based channel number (for instance, 4 for the alpha channel of a 4-component image).

Definition at line 345 of file imageFile.cxx.

const Filename & ImageFile::get_alpha_filename  )  const
 

Returns the alpha filename of the image file.

This is the name of the file that contains the alpha channel, if it is stored in a separate file, or the empty string if it is not.

Definition at line 322 of file imageFile.cxx.

TypeHandle ImageFile::get_class_type void   )  [inline, static]
 

Reimplemented from TypedWritable.

Reimplemented in DestTextureImage, PaletteImage, SourceTextureImage, and TextureImage.

Definition at line 99 of file imageFile.h.

const Filename & ImageFile::get_filename  )  const
 

Returns the primary filename of the image file.

Definition at line 303 of file imageFile.cxx.

References _properties, and nout.

Referenced by TextureImage::clear_source_basic_properties(), TextureImage::get_preferred_source(), TextureImage::is_newer_than(), TextureImage::is_used(), and PaletteImage::unplace().

int ImageFile::get_num_channels  )  const
 

Returns the number of channels of the image.

It is an error to call this unless has_num_channels() returns true.

Definition at line 155 of file imageFile.cxx.

References _properties.

Referenced by TextureImage::mark_eggs_stale().

const TextureProperties & ImageFile::get_properties  )  const
 

Returns the grouping properties of the image.

Definition at line 168 of file imageFile.cxx.

References Palettizer::_map_dirname, PaletteGroup::get_dirname(), NULL, and pal.

Referenced by TextureMemoryCounter::add_texture(), TextureImage::copy_unplaced(), DestTextureImage::DestTextureImage(), and TexturePlacement::get_name().

virtual TypeHandle ImageFile::get_type void   )  const [inline, virtual]
 

Reimplemented from TypedWritable.

Reimplemented in DestTextureImage, PaletteImage, SourceTextureImage, and TextureImage.

Definition at line 107 of file imageFile.h.

int ImageFile::get_x_size  )  const
 

Returns the size of the image file in pixels in the X direction.

It is an error to call this unless is_size_known() returns true.

Definition at line 104 of file imageFile.cxx.

References _properties, and TextureProperties::has_num_channels().

Referenced by TextureImage::copy_unplaced(), DestTextureImage::DestTextureImage(), TextureImage::is_used(), and TextureImage::mark_eggs_stale().

int ImageFile::get_y_size  )  const
 

Returns the size of the image file in pixels in the Y direction.

It is an error to call this unless is_size_known() returns true.

Definition at line 122 of file imageFile.cxx.

Referenced by TextureImage::copy_unplaced(), DestTextureImage::DestTextureImage(), TextureImage::is_used(), and TextureImage::mark_eggs_stale().

bool ImageFile::has_num_channels  )  const
 

Returns true if the number of channels in the image is known, false otherwise.

Definition at line 138 of file imageFile.cxx.

References _properties, and TextureProperties::clear_basic().

void ImageFile::init_type void   )  [inline, static]
 

Reimplemented from TypedWritable.

Reimplemented in DestTextureImage, PaletteImage, SourceTextureImage, and TextureImage.

Definition at line 102 of file imageFile.h.

References _type_handle.

bool ImageFile::is_size_known  )  const
 

Returns true if the size of the image file is known, false otherwise.

Definition at line 87 of file imageFile.cxx.

References _y_size, and nassertr.

Referenced by TextureImage::copy_unplaced(), DestTextureImage::DestTextureImage(), TexturePlacement::mark_eggs_stale(), and TextureImage::read_source_image().

void ImageFile::make_shadow_image const string &  basename  ) 
 

Sets up the ImageFile as a "shadow image" of a particular PaletteImage.

This is a temporary ImageFile that's used to read and write the shadow palette image, which is used to keep a working copy of the palette.

Definition at line 69 of file imageFile.cxx.

References _size_known.

void ImageFile::output_filename ostream &  out  )  const
 

Writes the filename (or pair of filenames) to the indicated output stream.

Definition at line 561 of file imageFile.cxx.

Referenced by TextureImage::copy_unplaced(), SourceTextureImage::get_type(), and DestTextureImage::get_type().

bool ImageFile::read PNMImage image  )  const
 

Reads in the image (or images, if the alpha_filename is separate) and stores it in the indicated PNMImage.

Returns true on success, false on failure.

Definition at line 389 of file imageFile.cxx.

void ImageFile::set_filename const string &  dirname,
const string &  basename
 

Sets the filename, and if applicable, the alpha_filename, from the indicated basename.

The extension appropriate to the image file type specified in _color_type (and _alpha_type) is automatically applied.

Definition at line 269 of file imageFile.cxx.

References _alpha_filename, TextureProperties::_alpha_type, _filename, _properties, Filename::empty(), Filename::exists(), NULL, and TextureProperties::uses_alpha().

void ImageFile::set_filename PaletteGroup group,
const string &  basename
 

Sets the filename, and if applicable, the alpha_filename, from the indicated basename.

The extension appropriate to the image file type specified in _color_type (and _alpha_type) is automatically applied.

Definition at line 223 of file imageFile.cxx.

void ImageFile::unlink  ) 
 

Deletes the image file or files.

Definition at line 513 of file imageFile.cxx.

References _alpha_file_channel, _alpha_filename, _filename, Palettizer::_read_pi_version, and DatagramIterator::get_uint8().

void ImageFile::update_egg_tex EggTexture egg_tex  )  const
 

Sets the indicated EggTexture to refer to this file.

Definition at line 533 of file imageFile.cxx.

Referenced by TextureReference::get_placement().

void ImageFile::update_properties const TextureProperties properties  ) 
 

If the indicate TextureProperties structure is more specific than this one, updates this one.

Definition at line 202 of file imageFile.cxx.

References TextureProperties::_color_type, _filename, _properties, Filename, PNMFileType::get_suggested_extension(), NULL, and Filename::set_extension().

bool ImageFile::write const PNMImage image  )  const
 

Writes out the image in the indicated PNMImage to the _filename and/or _alpha_filename.

Returns true on success, false on failure.

Definition at line 459 of file imageFile.cxx.

References _alpha_filename, and _properties.

void ImageFile::write_datagram BamWriter writer,
Datagram datagram
[virtual]
 

Fills the indicated datagram up with a binary representation of the current object, in preparation for writing to a Bam file.

Reimplemented from TypedWritable.

Reimplemented in DestTextureImage, PaletteImage, SourceTextureImage, and TextureImage.

Definition at line 581 of file imageFile.cxx.

Referenced by DestTextureImage::to_power_2().


Member Data Documentation

int ImageFile::_alpha_file_channel [protected]
 

Definition at line 84 of file imageFile.h.

Referenced by SourceTextureImage::SourceTextureImage(), and unlink().

Filename ImageFile::_alpha_filename [protected]
 

Definition at line 83 of file imageFile.h.

Referenced by exists(), set_filename(), SourceTextureImage::SourceTextureImage(), unlink(), and write().

Filename ImageFile::_filename [protected]
 

Definition at line 82 of file imageFile.h.

Referenced by exists(), set_filename(), SourceTextureImage::SourceTextureImage(), unlink(), and update_properties().

TextureProperties ImageFile::_properties [protected]
 

Definition at line 81 of file imageFile.h.

Referenced by DestTextureImage::DestTextureImage(), exists(), get_filename(), get_num_channels(), get_x_size(), has_num_channels(), TextureImage::mark_eggs_stale(), set_filename(), update_properties(), and write().

bool ImageFile::_size_known [protected]
 

Definition at line 86 of file imageFile.h.

Referenced by DestTextureImage::DestTextureImage(), SourceTextureImage::increment_egg_count(), make_shadow_image(), and TextureImage::mark_eggs_stale().

TypeHandle ImageFile::_type_handle [static, private]
 

Reimplemented from TypedWritable.

Reimplemented in DestTextureImage, PaletteImage, SourceTextureImage, and TextureImage.

Definition at line 35 of file imageFile.cxx.

Referenced by init_type().

int ImageFile::_x_size [protected]
 

Definition at line 87 of file imageFile.h.

Referenced by PaletteImage::check_solitary(), PaletteImage::ClearedRegion::ClearedRegion(), DestTextureImage::DestTextureImage(), TextureImage::mark_eggs_stale(), TextureImage::pre_txa_file(), PaletteImage::setup_shadow_image(), and PaletteImage::unplace().

int ImageFile::_y_size [protected]
 

Definition at line 87 of file imageFile.h.

Referenced by PaletteImage::check_solitary(), PaletteImage::ClearedRegion::ClearedRegion(), DestTextureImage::DestTextureImage(), is_size_known(), TextureImage::mark_eggs_stale(), TextureImage::pre_txa_file(), PaletteImage::setup_shadow_image(), and PaletteImage::unplace().


The documentation for this class was generated from the following files:
Generated on Fri May 2 03:27:19 2003 for Panda-Tool by doxygen1.3