Pyrogenesis  trunk
Classes | Typedefs | Functions
tex_codec.h File Reference
#include "tex.h"
#include "tex_internal.h"
Include dependency graph for tex_codec.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  ITexCodec
 virtual method table for TexCodecs. More...
 
class  TexCodecPng
 
class  TexCodecDds
 
class  TexCodecTga
 
class  TexCodecBmp
 

Typedefs

typedef const u8RowPtr
 allocate an array of row pointers that point into the given texture data. More...
 

Functions

Status tex_codec_for_filename (const OsPath &extension, const ITexCodec **c)
 Find codec that recognizes the desired output file extension. More...
 
Status tex_codec_for_header (const u8 *data, size_t data_size, const ITexCodec **c)
 find codec that recognizes the header's magic field. More...
 
Status tex_codec_transform (Tex *t, size_t transforms)
 transform the texture's pixel format. More...
 
std::vector< RowPtrtex_codec_alloc_rows (const u8 *data, size_t h, size_t pitch, size_t src_flags, size_t dst_orientation)
 
Status tex_codec_write (Tex *t, size_t transforms, const void *hdr, size_t hdr_size, DynArray *da)
 apply transforms and then copy header and image into output buffer. More...
 

Typedef Documentation

typedef const u8* RowPtr

allocate an array of row pointers that point into the given texture data.

for texture decoders that support output via row pointers (e.g. PNG), this allows flipping the image vertically (useful when matching bottom-up textures to a global orientation) directly, which is much more efficient than transforming later via copying all pixels.

Parameters
datathe texture data into which row pointers will point. note: we don't allocate it here because this function is needed for encoding, too (where data is already present).
hheight [pixels] of texture.
pitchsize [bytes] of one texture row, i.e. width*bytes_per_pixel.
src_flagsTexFlags of source texture. used to extract its orientation.
dst_orientationdesired orientation of the output data. can be one of TEX_BOTTOM_UP, TEX_TOP_DOWN, or 0 for the "global orientation". depending on src and dst, the row array is flipped if necessary.

Function Documentation

std::vector<RowPtr> tex_codec_alloc_rows ( const u8 data,
size_t  h,
size_t  pitch,
size_t  src_flags,
size_t  dst_orientation 
)
Status tex_codec_for_filename ( const OsPath extension,
const ITexCodec **  c 
)

Find codec that recognizes the desired output file extension.

Parameters
extension
c(out) vtbl of responsible codec
Returns
Status; ERR::RES_UNKNOWN_FORMAT (without warning, because this is called by tex_is_known_extension) if no codec indicates they can handle the given extension.
Status tex_codec_for_header ( const u8 data,
size_t  data_size,
const ITexCodec **  c 
)

find codec that recognizes the header's magic field.

Parameters
datatypically contents of file, but need only include the (first 4 bytes of) header.
data_size[bytes]
c(out) vtbl of responsible codec
Returns
Status; ERR::RES_UNKNOWN_FORMAT if no codec indicates they can handle the given format (header).
Status tex_codec_transform ( Tex t,
size_t  transforms 
)

transform the texture's pixel format.

tries each codec's transform method once, or until one indicates success.

Parameters
ttexture object
transformsOR-ed combination of TEX_* flags that are to be changed.
Returns
Status
Status tex_codec_write ( Tex t,
size_t  transforms,
const void *  hdr,
size_t  hdr_size,
DynArray da 
)

apply transforms and then copy header and image into output buffer.

Parameters
tinput texture object
transformstransformations to be applied to pixel format
hdrheader data
hdr_size[bytes]
daoutput data array (will be expanded as necessary)
Returns
Status