Pyrogenesis  trunk
Public Member Functions | List of all members
TexCodecBmp Class Reference

#include <tex_codec.h>

Inheritance diagram for TexCodecBmp:
Inheritance graph
[legend]
Collaboration diagram for TexCodecBmp:
Collaboration graph
[legend]

Public Member Functions

virtual Status decode (u8 *data, size_t size, Tex *RESTRICT t) const
 decode the file into a Tex structure. More...
 
virtual Status encode (Tex *RESTRICT t, DynArray *RESTRICT da) const
 encode the texture data into the codec's file format (in memory). More...
 
virtual Status transform (Tex *t, size_t transforms) const
 transform the texture's pixel format. More...
 
virtual bool is_hdr (const u8 *file) const
 indicate if the data appears to be an instance of this codec's header, i.e. More...
 
virtual bool is_ext (const OsPath &extension) const
 is the extension that of a file format supported by this codec? More...
 
virtual size_t hdr_size (const u8 *file) const
 return size of the file header supported by this codec. More...
 
virtual const wchar_t * get_name () const
 name of codec for debug purposes. More...
 

Additional Inherited Members

- Private Member Functions inherited from ITexCodec
virtual ~ITexCodec ()
 

Member Function Documentation

◆ decode()

Status TexCodecBmp::decode ( u8 data,
size_t  size,
Tex *RESTRICT  t 
) const
virtual

decode the file into a Tex structure.

Parameters
datainput data array (non-const, because the texture may have to be flipped in-place - see "texture orientation").
size[bytes] of data, always >= 4 (this is usually enough to compare the header's "magic" field, and no legitimate file will be smaller)
toutput texture object
Returns
Status

Implements ITexCodec.

◆ encode()

Status TexCodecBmp::encode ( Tex *RESTRICT  t,
DynArray *RESTRICT  da 
) const
virtual

encode the texture data into the codec's file format (in memory).

Parameters
tinput texture object. note: non-const because encoding may require a Tex::transform.
daoutput data array, allocated by codec. rationale: some codecs cannot calculate the output size beforehand (e.g. PNG output via libpng), so the output memory cannot be allocated by the caller.
Returns
Status

Implements ITexCodec.

◆ get_name()

virtual const wchar_t* TexCodecBmp::get_name ( ) const
inlinevirtual

name of codec for debug purposes.

typically set via TEX_CODEC_REGISTER.

Implements ITexCodec.

◆ hdr_size()

size_t TexCodecBmp::hdr_size ( const u8 file) const
virtual

return size of the file header supported by this codec.

Parameters
filethe specific header to return length of (taking its variable-length fields into account). if NULL, return minimum guaranteed header size, i.e. the header without any variable-length fields.
Returns
size [bytes]

Implements ITexCodec.

◆ is_ext()

bool TexCodecBmp::is_ext ( const OsPath extension) const
virtual

is the extension that of a file format supported by this codec?

rationale: cannot just return the extension string and have caller compare it (-> smaller code) because a codec's file format may have several valid extensions (e.g. jpg and jpeg).

Parameters
extension(including '.')
Returns
bool

Implements ITexCodec.

◆ is_hdr()

bool TexCodecBmp::is_hdr ( const u8 file) const
virtual

indicate if the data appears to be an instance of this codec's header, i.e.

can this codec decode it?

Parameters
fileinput data; only guaranteed to be 4 bytes! (this should be enough to examine the header's 'magic' field)
Returns
bool

Implements ITexCodec.

◆ transform()

Status TexCodecBmp::transform ( Tex t,
size_t  transforms 
) const
virtual

transform the texture's pixel format.

Parameters
ttexture object
transformsOR-ed combination of TEX_* flags that are to be changed. note: the codec needs only handle situations specific to its format; generic pixel format transforms are handled by the caller.

Implements ITexCodec.


The documentation for this class was generated from the following files: