#include "tex.h"
#include "tex_internal.h"
Go to the source code of this file.
|
typedef const u8 * | RowPtr |
| allocate an array of row pointers that point into the given texture data. More...
|
|
|
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< 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_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...
|
|
◆ 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
-
data | the 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). |
h | height [pixels] of texture. |
pitch | size [bytes] of one texture row, i.e. width*bytes_per_pixel. |
src_flags | TexFlags of source texture. used to extract its orientation. |
dst_orientation | desired 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. |
◆ tex_codec_alloc_rows()
std::vector< RowPtr > tex_codec_alloc_rows |
( |
const u8 * |
data, |
|
|
size_t |
h, |
|
|
size_t |
pitch, |
|
|
size_t |
src_flags, |
|
|
size_t |
dst_orientation |
|
) |
| |
◆ tex_codec_for_filename()
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.
◆ tex_codec_for_header()
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
-
data | typically 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).
◆ tex_codec_transform()
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
-
t | texture object |
transforms | OR-ed combination of TEX_* flags that are to be changed. |
- Returns
- Status
◆ tex_codec_write()
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
-
t | input texture object |
transforms | transformations to be applied to pixel format |
hdr | header data |
hdr_size | [bytes] |
da | output data array (will be expanded as necessary) |
- Returns
- Status