27#ifndef INCLUDED_TEX_CODEC
28#define INCLUDED_TEX_CODEC
125 virtual bool is_hdr(
const u8* file)
const;
127 virtual size_t hdr_size(
const u8* file)
const;
129 static const wchar_t *name = L
"png";
139 virtual bool is_hdr(
const u8* file)
const;
141 virtual size_t hdr_size(
const u8* file)
const;
143 static const wchar_t *name = L
"dds";
153 virtual bool is_hdr(
const u8* file)
const;
155 virtual size_t hdr_size(
const u8* file)
const;
157 static const wchar_t *name = L
"tga";
167 virtual bool is_hdr(
const u8* file)
const;
169 virtual size_t hdr_size(
const u8* file)
const;
171 static const wchar_t *name = L
"bmp";
230extern std::vector<RowPtr>
tex_codec_alloc_rows(
const u8* data,
size_t h,
size_t pitch,
size_t src_flags,
size_t dst_orientation);
virtual method table for TexCodecs.
Definition: tex_codec.h:40
virtual ~ITexCodec()
Definition: tex_codec.h:117
virtual bool is_hdr(const u8 *file) const =0
indicate if the data appears to be an instance of this codec's header, i.e.
virtual const wchar_t * get_name() const =0
name of codec for debug purposes.
virtual Status encode(Tex *RESTRICT t, DynArray *RESTRICT da) const =0
encode the texture data into the codec's file format (in memory).
virtual size_t hdr_size(const u8 *file) const =0
return size of the file header supported by this codec.
virtual Status decode(u8 *data, size_t size, Tex *RESTRICT t) const =0
decode the file into a Tex structure.
virtual Status transform(Tex *t, size_t transforms) const =0
transform the texture's pixel format.
virtual bool is_ext(const OsPath &extension) const =0
is the extension that of a file format supported by this codec?
Definition: tex_codec.h:162
virtual Status encode(Tex *RESTRICT t, DynArray *RESTRICT da) const
encode the texture data into the codec's file format (in memory).
Definition: tex_bmp.cpp:127
virtual bool is_ext(const OsPath &extension) const
is the extension that of a file format supported by this codec?
Definition: tex_bmp.cpp:77
virtual const wchar_t * get_name() const
name of codec for debug purposes.
Definition: tex_codec.h:170
virtual size_t hdr_size(const u8 *file) const
return size of the file header supported by this codec.
Definition: tex_bmp.cpp:83
virtual Status transform(Tex *t, size_t transforms) const
transform the texture's pixel format.
Definition: tex_bmp.cpp:63
virtual Status decode(u8 *data, size_t size, Tex *RESTRICT t) const
decode the file into a Tex structure.
Definition: tex_bmp.cpp:98
virtual bool is_hdr(const u8 *file) const
indicate if the data appears to be an instance of this codec's header, i.e.
Definition: tex_bmp.cpp:69
Definition: tex_codec.h:134
virtual Status transform(Tex *t, size_t transforms) const
transform the texture's pixel format.
Definition: tex_dds.cpp:630
virtual bool is_ext(const OsPath &extension) const
is the extension that of a file format supported by this codec?
Definition: tex_dds.cpp:600
virtual Status decode(u8 *data, size_t size, Tex *RESTRICT t) const
decode the file into a Tex structure.
Definition: tex_dds.cpp:612
virtual Status encode(Tex *RESTRICT t, DynArray *RESTRICT da) const
encode the texture data into the codec's file format (in memory).
Definition: tex_dds.cpp:620
virtual const wchar_t * get_name() const
name of codec for debug purposes.
Definition: tex_codec.h:142
virtual size_t hdr_size(const u8 *file) const
return size of the file header supported by this codec.
Definition: tex_dds.cpp:606
virtual bool is_hdr(const u8 *file) const
indicate if the data appears to be an instance of this codec's header, i.e.
Definition: tex_dds.cpp:594
Definition: tex_codec.h:120
virtual Status transform(Tex *t, size_t transforms) const
transform the texture's pixel format.
Definition: tex_png.cpp:110
virtual bool is_ext(const OsPath &extension) const
is the extension that of a file format supported by this codec?
Definition: tex_png.cpp:249
virtual size_t hdr_size(const u8 *file) const
return size of the file header supported by this codec.
Definition: tex_png.cpp:255
virtual Status encode(Tex *RESTRICT t, DynArray *RESTRICT da) const
encode the texture data into the codec's file format (in memory).
Definition: tex_png.cpp:307
virtual const wchar_t * get_name() const
name of codec for debug purposes.
Definition: tex_codec.h:128
virtual Status decode(u8 *data, size_t size, Tex *RESTRICT t) const
decode the file into a Tex structure.
Definition: tex_png.cpp:272
virtual bool is_hdr(const u8 *file) const
indicate if the data appears to be an instance of this codec's header, i.e.
Definition: tex_png.cpp:241
Definition: tex_codec.h:148
virtual Status decode(u8 *data, size_t size, Tex *RESTRICT t) const
decode the file into a Tex structure.
Definition: tex_tga.cpp:115
virtual size_t hdr_size(const u8 *file) const
return size of the file header supported by this codec.
Definition: tex_tga.cpp:102
virtual Status transform(Tex *t, size_t transforms) const
transform the texture's pixel format.
Definition: tex_tga.cpp:70
virtual Status encode(Tex *RESTRICT t, DynArray *RESTRICT da) const
encode the texture data into the codec's file format (in memory).
Definition: tex_tga.cpp:147
virtual bool is_hdr(const u8 *file) const
indicate if the data appears to be an instance of this codec's header, i.e.
Definition: tex_tga.cpp:76
virtual const wchar_t * get_name() const
name of codec for debug purposes.
Definition: tex_codec.h:156
virtual bool is_ext(const OsPath &extension) const
is the extension that of a file format supported by this codec?
Definition: tex_tga.cpp:96
Stores all data describing an image.
Definition: tex.h:209
#define RESTRICT
Definition: code_annotation.h:334
i64 Status
Error handling system.
Definition: status.h:173
provides a memory range that can be expanded but doesn't waste physical memory or relocate itself.
Definition: dynarray.h:40
Status tex_codec_for_filename(const OsPath &extension, const ITexCodec **c)
Find codec that recognizes the desired output file extension.
Definition: tex_codec.cpp:50
const u8 * RowPtr
allocate an array of row pointers that point into the given texture data.
Definition: tex_codec.h:229
std::vector< RowPtr > tex_codec_alloc_rows(const u8 *data, size_t h, size_t pitch, size_t src_flags, size_t dst_orientation)
Definition: tex_codec.cpp:120
Status tex_codec_for_header(const u8 *data, size_t data_size, const ITexCodec **c)
find codec that recognizes the header's magic field.
Definition: tex_codec.cpp:66
Status tex_codec_transform(Tex *t, size_t transforms)
transform the texture's pixel format.
Definition: tex_codec.cpp:84
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.
Definition: tex_codec.cpp:142
uint8_t u8
Definition: types.h:37