27 #include "precompiled.h"
67 for(*c = codecs; *c; *c = (*c)->
next)
70 if((*c)->is_ext(extension))
85 for(*c = codecs; *c; *c = (*c)->
next)
88 if((*c)->is_hdr(file))
103 return prev_codec->
next;
114 Status err = c->transform(t, transforms);
136 #define REGISTER_CODEC(name) extern void name##_register(); name##_register()
142 #undef REGISTER_CODEC
154 std::vector<RowPtr>
tex_codec_alloc_rows(
const u8* data,
size_t h,
size_t pitch,
size_t src_flags,
size_t dst_orientation)
158 std::vector<RowPtr> rows(h);
161 RowPtr pos = flip? data+pitch*(h-1) : data;
163 const RowPtr end = flip? data-pitch : data+pitch*h;
165 for(
size_t i = 0; i < h; i++)
Status tex_codec_for_filename(const OsPath &extension, const TexCodecVTbl **c)
Find codec that recognizes the desired output file extension.
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.
const Status TEX_CODEC_CANNOT_HANDLE
const TexCodecVTbl * tex_codec_next(const TexCodecVTbl *prev_codec)
enumerate all registered codecs.
static const TexCodecVTbl * codecs
provides a memory range that can be expanded but doesn't waste physical memory or relocate itself...
const Status TEX_INCOMPLETE_HEADER
#define REGISTER_CODEC(name)
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
std::vector< RowPtr > tex_codec_alloc_rows(const u8 *data, size_t h, size_t pitch, size_t src_flags, size_t dst_orientation)
const TexCodecVTbl * next
intrusive linked-list of codecs: more convenient than fixed-size static storage.
u8 * tex_get_data(const Tex *t)
rationale: since Tex is a struct, its fields are accessible to callers.
bool tex_orientations_match(size_t src_flags, size_t dst_orientation)
indicate if the two vertical orientations match.
const Status TEX_UNKNOWN_FORMAT
Status da_append(DynArray *da, const void *data, size_t size)
"write" to array, i.e.
i64 Status
Error handling system.
stores all data describing an image.
#define DEBUG_WARN_ERR(status)
display the error dialog with text corresponding to the given error code.
Status tex_codec_transform(Tex *t, size_t transforms)
transform the texture's pixel format.
#define WARN_RETURN(status)
void tex_codec_register_all()
Manually register codecs.
size_t tex_img_size(const Tex *t)
return total byte size of the image pixels.
const u8 * RowPtr
allocate an array of row pointers that point into the given texture data.
Status tex_transform(Tex *t, size_t transforms)
Change <t>'s pixel format.
void tex_codec_unregister_all()
remove all codecs that have been registered.
virtual method table for TexCodecs.
Status tex_codec_for_header(const u8 *file, size_t file_size, const TexCodecVTbl **c)
find codec that recognizes the header's magic field.
int tex_codec_register(TexCodecVTbl *c)
add this vtbl to the codec list.
#define RETURN_STATUS_IF_ERR(expression)