27#ifndef INCLUDED_TEX_CODEC
28#define INCLUDED_TEX_CODEC
94 virtual bool is_hdr(
const std::uint8_t* file)
const = 0;
117 virtual size_t hdr_size(
const std::uint8_t* file)
const = 0;
132 virtual bool is_hdr(
const std::uint8_t* file)
const;
134 virtual size_t hdr_size(
const std::uint8_t* file)
const;
136 static const wchar_t *name = L
"png";
146 virtual bool is_hdr(
const std::uint8_t* file)
const;
148 virtual size_t hdr_size(
const std::uint8_t* file)
const;
150 static const wchar_t *name = L
"dds";
160 virtual bool is_hdr(
const std::uint8_t* file)
const;
162 virtual size_t hdr_size(
const std::uint8_t* file)
const;
164 static const wchar_t *name = L
"tga";
174 virtual bool is_hdr(
const std::uint8_t* file)
const;
176 virtual size_t hdr_size(
const std::uint8_t* file)
const;
178 static const wchar_t *name = L
"bmp";
237extern std::vector<RowPtr>
tex_codec_alloc_rows(
const std::uint8_t* data,
size_t h,
size_t pitch,
size_t src_flags,
size_t dst_orientation);
virtual method table for TexCodecs.
Definition: tex_codec.h:47
virtual ~ITexCodec()
Definition: tex_codec.h:124
virtual bool is_hdr(const std::uint8_t *file) const =0
indicate if the data appears to be an instance of this codec's header, i.e.
virtual size_t hdr_size(const std::uint8_t *file) const =0
return size of the file header supported by this codec.
virtual Status decode(std::uint8_t *data, size_t size, Tex *RESTRICT t) const =0
decode the file into a Tex structure.
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 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:169
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:135
virtual bool is_ext(const OsPath &extension) const
is the extension that of a file format supported by this codec?
Definition: tex_bmp.cpp:85
virtual const wchar_t * get_name() const
name of codec for debug purposes.
Definition: tex_codec.h:177
virtual Status decode(std::uint8_t *data, size_t size, Tex *RESTRICT t) const
decode the file into a Tex structure.
Definition: tex_bmp.cpp:106
virtual bool is_hdr(const std::uint8_t *file) const
indicate if the data appears to be an instance of this codec's header, i.e.
Definition: tex_bmp.cpp:77
virtual Status transform(Tex *t, size_t transforms) const
transform the texture's pixel format.
Definition: tex_bmp.cpp:71
virtual size_t hdr_size(const std::uint8_t *file) const
return size of the file header supported by this codec.
Definition: tex_bmp.cpp:91
Definition: tex_codec.h:141
virtual Status transform(Tex *t, size_t transforms) const
transform the texture's pixel format.
Definition: tex_dds.cpp:642
virtual bool is_hdr(const std::uint8_t *file) const
indicate if the data appears to be an instance of this codec's header, i.e.
Definition: tex_dds.cpp:609
virtual size_t hdr_size(const std::uint8_t *file) const
return size of the file header supported by this codec.
Definition: tex_dds.cpp:621
virtual bool is_ext(const OsPath &extension) const
is the extension that of a file format supported by this codec?
Definition: tex_dds.cpp:615
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:635
virtual const wchar_t * get_name() const
name of codec for debug purposes.
Definition: tex_codec.h:149
virtual Status decode(std::uint8_t *data, size_t size, Tex *RESTRICT t) const
decode the file into a Tex structure.
Definition: tex_dds.cpp:627
Definition: tex_codec.h:127
virtual Status transform(Tex *t, size_t transforms) const
transform the texture's pixel format.
Definition: tex_png.cpp:122
virtual bool is_ext(const OsPath &extension) const
is the extension that of a file format supported by this codec?
Definition: tex_png.cpp:261
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:315
virtual bool is_hdr(const std::uint8_t *file) const
indicate if the data appears to be an instance of this codec's header, i.e.
Definition: tex_png.cpp:253
virtual const wchar_t * get_name() const
name of codec for debug purposes.
Definition: tex_codec.h:135
virtual Status decode(std::uint8_t *data, size_t size, Tex *RESTRICT t) const
decode the file into a Tex structure.
Definition: tex_png.cpp:282
virtual size_t hdr_size(const std::uint8_t *file) const
return size of the file header supported by this codec.
Definition: tex_png.cpp:267
Definition: tex_codec.h:155
virtual Status transform(Tex *t, size_t transforms) const
transform the texture's pixel format.
Definition: tex_tga.cpp:77
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:154
virtual size_t hdr_size(const std::uint8_t *file) const
return size of the file header supported by this codec.
Definition: tex_tga.cpp:109
virtual bool is_hdr(const std::uint8_t *file) const
indicate if the data appears to be an instance of this codec's header, i.e.
Definition: tex_tga.cpp:83
virtual const wchar_t * get_name() const
name of codec for debug purposes.
Definition: tex_codec.h:163
virtual Status decode(std::uint8_t *data, size_t size, Tex *RESTRICT t) const
decode the file into a Tex structure.
Definition: tex_tga.cpp:122
virtual bool is_ext(const OsPath &extension) const
is the extension that of a file format supported by this codec?
Definition: tex_tga.cpp:103
Stores all data describing an image.
Definition: tex.h:214
#define RESTRICT
Definition: code_annotation.h:267
std::int64_t Status
Error handling system.
Definition: status.h:174
provides a memory range that can be expanded but doesn't waste physical memory or relocate itself.
Definition: dynarray.h:42
Status tex_codec_for_filename(const OsPath &extension, const ITexCodec **c)
Find codec that recognizes the desired output file extension.
Definition: tex_codec.cpp:51
std::vector< RowPtr > tex_codec_alloc_rows(const std::uint8_t *data, size_t h, size_t pitch, size_t src_flags, size_t dst_orientation)
Definition: tex_codec.cpp:121
Status tex_codec_transform(Tex *t, size_t transforms)
transform the texture's pixel format.
Definition: tex_codec.cpp:85
const std::uint8_t * RowPtr
allocate an array of row pointers that point into the given texture data.
Definition: tex_codec.h:236
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:144
Status tex_codec_for_header(const std::uint8_t *data, size_t data_size, const ITexCodec **c)
find codec that recognizes the header's magic field.
Definition: tex_codec.cpp:67