Panda3D
|
This is the base class of both TextureImage and PaletteImage. More...
#include "imageFile.h"
Public Member Functions | |
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. | |
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. | |
bool | exists () const |
Returns true if the file or files named by the image file exist, false otherwise. | |
int | get_alpha_file_channel () const |
Returns the particular channel number of the alpha image file from which the alpha channel should be extracted. | |
const Filename & | get_alpha_filename () const |
Returns the alpha filename of the image file. | |
const Filename & | get_filename () const |
Returns the primary filename of the image file. | |
int | get_num_channels () const |
Returns the number of channels of the image. | |
const TextureProperties & | get_properties () const |
Returns the grouping properties of the image. | |
virtual TypeHandle | get_type () const |
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. | |
bool | is_size_known () const |
Returns true if the size of the image file is known, false otherwise. | |
bool | make_shadow_image (const std::string &basename) |
Sets up the ImageFile as a "shadow image" of a particular PaletteImage. | |
void | output_filename (std::ostream &out) const |
Writes the filename (or pair of filenames) to the indicated output stream. | |
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 | set_filename (const std::string &dirname, const std::string &basename) |
Sets the filename, and if applicable, the alpha_filename, from the indicated basename. | |
bool | set_filename (PaletteGroup *group, const std::string &basename) |
Sets the filename, and if applicable, the alpha_filename, from the indicated basename. | |
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 | update_properties (const TextureProperties &properties) |
If the indicate TextureProperties structure is more specific than this one, updates this one. | |
bool | write (const PNMImage &image) const |
Writes out the image in the indicated PNMImage to the _filename and/or _alpha_filename. | |
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. | |
![]() | |
TypedWritable (const TypedWritable ©) | |
virtual ReferenceCount * | as_reference_count () |
Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type. | |
vector_uchar | encode_to_bam_stream () const |
Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a bytes object. | |
bool | encode_to_bam_stream (vector_uchar &data, BamWriter *writer=nullptr) const |
Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string. | |
virtual void | finalize (BamReader *manager) |
Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed. | |
virtual TypeHandle | force_init_type () |
UpdateSeq | get_bam_modified () const |
Returns the current bam_modified counter. | |
void | mark_bam_modified () |
Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams. | |
void | operator= (const TypedWritable ©) |
virtual bool | require_fully_complete () const |
Some objects require all of their nested pointers to have been completed before the objects themselves can be completed. | |
virtual void | update_bam_nested (BamWriter *manager) |
Called by the BamWriter when this object has not itself been modified recently, but it should check its nested objects for updates. | |
![]() | |
TypedObject (const TypedObject ©)=default | |
TypedObject * | as_typed_object () |
Returns the object, upcast (if necessary) to a TypedObject pointer. | |
const TypedObject * | as_typed_object () const |
Returns the object, upcast (if necessary) to a TypedObject pointer. | |
int | get_best_parent_from_Set (const std::set< int > &) const |
int | get_type_index () const |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. | |
bool | is_exact_type (TypeHandle handle) const |
Returns true if the current object is the indicated type exactly. | |
bool | is_of_type (TypeHandle handle) const |
Returns true if the current object is or derives from the indicated type. | |
TypedObject & | operator= (const TypedObject ©)=default |
![]() | |
void | operator delete (void *, void *) |
void | operator delete (void *ptr) |
void | operator delete[] (void *, void *) |
void | operator delete[] (void *ptr) |
void * | operator new (size_t size) |
void * | operator new (size_t size, void *ptr) |
void * | operator new[] (size_t size) |
void * | operator new[] (size_t size, void *ptr) |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
![]() | |
static bool | decode_raw_from_bam_stream (TypedWritable *&ptr, ReferenceCount *&ref_ptr, vector_uchar data, BamReader *reader=nullptr) |
Reads the bytes created by a previous call to encode_to_bam_stream(), and extracts the single object on those bytes. | |
static TypeHandle | get_class_type () |
static void | init_type () |
![]() | |
static TypeHandle | get_class_type () |
static void | init_type () |
This function is declared non-inline to work around a compiler bug in g++ 2.96. | |
Additional Inherited Members | |
![]() | |
get_type | |
![]() | |
static TypedWritable *const | Null = nullptr |
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 33 of file imageFile.h.
ImageFile::ImageFile | ( | ) |
Definition at line 34 of file imageFile.cxx.
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 127 of file imageFile.cxx.
References TextureProperties::clear_basic().
Referenced by TextureImage::clear_source_basic_properties().
|
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 453 of file imageFile.cxx.
References TypedWritable::complete_pointers(), and TextureProperties::complete_pointers().
Referenced by PaletteImage::complete_pointers(), SourceTextureImage::complete_pointers(), and TextureImage::complete_pointers().
bool ImageFile::exists | ( | ) | const |
Returns true if the file or files named by the image file exist, false otherwise.
Definition at line 255 of file imageFile.cxx.
References Filename::exists(), and TextureProperties::uses_alpha().
Referenced by TextureImage::get_preferred_source(), and PaletteImage::update_image().
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 245 of file imageFile.cxx.
Referenced by TextureImage::complete_pointers(), and PaletteGroup::prepare().
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 234 of file imageFile.cxx.
Referenced by TextureImage::complete_pointers(), and PaletteGroup::prepare().
|
inlinestatic |
Definition at line 83 of file imageFile.h.
const Filename & ImageFile::get_filename | ( | ) | const |
Returns the primary filename of the image file.
Definition at line 224 of file imageFile.cxx.
Referenced by TextureImage::complete_pointers(), DestTextureImage::copy_if_stale(), TextureImage::copy_unplaced(), TextureImage::get_preferred_source(), TextureImage::is_newer_than(), PaletteImage::optimal_resize(), PaletteGroup::prepare(), PaletteImage::update_filename(), PaletteImage::update_image(), and TextureImage::write_scale_info().
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 110 of file imageFile.cxx.
References TextureProperties::get_num_channels().
Referenced by DestTextureImage::copy(), DestTextureImage::copy_if_stale(), TextureReference::from_egg(), TextureImage::post_txa_file(), PT(), TextureReference::update_egg(), and TextureImage::write_scale_info().
const TextureProperties & ImageFile::get_properties | ( | ) | const |
Returns the grouping properties of the image.
Definition at line 118 of file imageFile.cxx.
Referenced by TexturePlacement::get_properties(), TextureImage::pre_txa_file(), PT(), and TextureImage::write_source_pathnames().
|
inlinevirtual |
Reimplemented from TypedWritable.
Definition at line 91 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 81 of file imageFile.cxx.
References is_size_known().
Referenced by TexturePlacement::compute_tex_matrix(), DestTextureImage::copy_if_stale(), PaletteImage::count_coverage(), PaletteImage::count_utilization(), TexturePlacement::fill_image(), TexturePlacement::fill_swapped_image(), TextureImage::get_preferred_source(), TxaLine::match_texture(), TextureImage::post_txa_file(), PT(), TextureImage::write_scale_info(), and TextureImage::write_source_pathnames().
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 91 of file imageFile.cxx.
References is_size_known().
Referenced by TexturePlacement::compute_tex_matrix(), DestTextureImage::copy_if_stale(), PaletteImage::count_coverage(), PaletteImage::count_utilization(), TexturePlacement::fill_image(), TexturePlacement::fill_swapped_image(), TextureImage::get_preferred_source(), TxaLine::match_texture(), TextureImage::post_txa_file(), PT(), TextureImage::write_scale_info(), and TextureImage::write_source_pathnames().
bool ImageFile::has_num_channels | ( | ) | const |
Returns true if the number of channels in the image is known, false otherwise.
Definition at line 101 of file imageFile.cxx.
References TextureProperties::has_num_channels().
Referenced by TextureReference::update_egg().
|
inlinestatic |
Definition at line 86 of file imageFile.h.
bool ImageFile::is_size_known | ( | ) | const |
Returns true if the size of the image file is known, false otherwise.
Definition at line 72 of file imageFile.cxx.
Referenced by TexturePlacement::determine_size(), get_x_size(), get_y_size(), TextureImage::write_scale_info(), and TextureImage::write_source_pathnames().
bool ImageFile::make_shadow_image | ( | const std::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.
Returns true if the filename changes from what it was previously, false otherwise.
Definition at line 50 of file imageFile.cxx.
References set_filename().
Referenced by PaletteImage::setup_shadow_image().
void ImageFile::output_filename | ( | std::ostream & | out | ) | const |
Writes the filename (or pair of filenames) to the indicated output stream.
Definition at line 423 of file imageFile.cxx.
References FilenameUnifier::make_user_filename(), and TextureProperties::uses_alpha().
Referenced by PalettePage::write_image_info(), and TextureImage::write_source_pathnames().
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 276 of file imageFile.cxx.
References PNMImage::add_alpha(), Filename::exists(), PNMImage::get_alpha(), PNMImage::get_channel_val(), PNMImage::get_gray(), PNMImageHeader::get_num_channels, PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), FilenameUnifier::make_user_filename(), PNMImage::read(), PNMImage::set_alpha(), and PNMImageHeader::set_type().
Referenced by TextureImage::read_source_image().
bool ImageFile::set_filename | ( | const std::string & | dirname, |
const std::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.
Returns true if the filename changes from what it was previously, false otherwise.
Definition at line 187 of file imageFile.cxx.
References Filename::get_fullpath_wo_extension(), PNMFileType::get_suggested_extension, Filename::set_extension(), and Filename::standardize().
bool ImageFile::set_filename | ( | PaletteGroup * | group, |
const std::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.
Returns true if the filename changes from what it was previously, false otherwise.
Definition at line 149 of file imageFile.cxx.
References PaletteGroup::get_dirname(), and set_filename().
Referenced by make_shadow_image(), and set_filename().
void ImageFile::unlink | ( | ) |
Deletes the image file or files.
Definition at line 387 of file imageFile.cxx.
References Filename::exists(), FilenameUnifier::make_user_filename(), and Filename::unlink().
void ImageFile::update_egg_tex | ( | EggTexture * | egg_tex | ) | const |
Sets the indicated EggTexture to refer to this file.
Definition at line 402 of file imageFile.cxx.
References EggTexture::clear_alpha_file_channel, FilenameUnifier::make_egg_filename(), EggTexture::set_alpha_file_channel, EggTexture::set_alpha_filename, TextureProperties::update_egg_tex(), and TextureProperties::uses_alpha().
Referenced by TextureReference::update_egg().
void ImageFile::update_properties | ( | const TextureProperties & | properties | ) |
If the indicate TextureProperties structure is more specific than this one, updates this one.
Definition at line 136 of file imageFile.cxx.
References TextureProperties::update_properties().
Referenced by TextureReference::apply_properties_to_source(), and TextureReference::from_egg().
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 338 of file imageFile.cxx.
References Filename::exists(), PNMImage::get_alpha_val(), PNMImageHeader::get_maxval, PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), PNMImageHeader::has_alpha(), Filename::make_dir(), FilenameUnifier::make_user_filename(), PNMImage::remove_alpha(), PNMImage::set_gray_val(), Filename::unlink(), and PNMImage::write().
Referenced by DestTextureImage::copy(), and PaletteImage::update_image().
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 435 of file imageFile.cxx.
References Datagram::add_bool(), Datagram::add_int32(), Datagram::add_string(), Datagram::add_uint8(), FilenameUnifier::make_bam_filename(), TypedWritable::write_datagram(), and TextureProperties::write_datagram().
Referenced by DestTextureImage::write_datagram(), PaletteImage::write_datagram(), SourceTextureImage::write_datagram(), and TextureImage::write_datagram().