274 Status decode(
const std::shared_ptr<u8>& data,
size_t data_size);
309 Status wrap(
size_t w,
size_t h,
size_t bpp,
size_t flags,
const std::shared_ptr<u8>& data,
size_t ofs);
394typedef void (*
MipmapCB)(
size_t level,
size_t level_w,
size_t level_h,
const u8*
RESTRICT level_data,
size_t level_data_size,
void*
RESTRICT cbData);
Stores all data describing an image.
Definition: tex.h:209
Status wrap(size_t w, size_t h, size_t bpp, size_t flags, const std::shared_ptr< u8 > &data, size_t ofs)
store the given image data into a Tex object; this will be as if it had been loaded via tex_load.
Definition: tex.cpp:588
const std::vector< MIPLevel > & GetMIPLevels() const
Definition: tex.h:344
size_t m_DataSize
Definition: tex.h:227
size_t m_Flags
see TexFlags and "Format Conversion" in docs.
Definition: tex.h:242
size_t m_Height
Definition: tex.h:238
Status validate() const
Is the texture object valid and self-consistent?
Definition: tex.cpp:57
std::shared_ptr< u8 > m_Data
file buffer or image data.
Definition: tex.h:225
u8 * get_data()
return a pointer to the image data (pixels), taking into account any header(s) that may come before i...
Definition: tex.cpp:625
size_t img_size() const
return total byte size of the image pixels.
Definition: tex.cpp:681
u32 get_average_color() const
return the ARGB value of the 1x1 mipmap level of the texture.
Definition: tex.cpp:637
Status encode(const OsPath &extension, DynArray *da)
encode a texture into a memory buffer in the desired file format.
Definition: tex.cpp:750
Status transform_to(size_t new_flags)
Change the pixel format (2nd version) (note: this is equivalent to Tex::transform(t,...
Definition: tex.cpp:489
size_t m_Ofs
offset to image data in file.
Definition: tex.h:235
std::vector< MIPLevel > m_MIPLevels
Definition: tex.h:365
~Tex()
Definition: tex.h:244
Status decode(const std::shared_ptr< u8 > &data, size_t data_size)
decode an in-memory texture file into texture object.
Definition: tex.cpp:715
void UpdateMIPLevels()
Definition: tex.cpp:777
Status transform(size_t transforms)
Change the pixel format.
Definition: tex.cpp:460
size_t m_Width
Definition: tex.h:237
size_t m_Bpp
Definition: tex.h:239
void free()
free all resources associated with the image and make further use of it impossible.
Definition: tex.cpp:608
#define RESTRICT
Definition: code_annotation.h:334
const Status TEX_NOT_8BIT_PRECISION
Definition: tex.h:119
const Status TEX_INVALID_LAYOUT
Definition: tex.h:120
const Status TEX_INVALID_SIZE
Definition: tex.h:122
const Status TEX_UNKNOWN_FORMAT
Definition: tex.h:115
const Status TEX_INVALID_COLOR_TYPE
Definition: tex.h:118
const Status TEX_COMPRESSED
Definition: tex.h:121
const Status TEX_INCOMPLETE_HEADER
Definition: tex.h:116
const Status TEX_FMT_INVALID
Definition: tex.h:117
const Status TEX_CODEC_CANNOT_HANDLE
Definition: tex.h:132
const Status TEX_INVALID_DATA
Definition: tex.h:127
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
u32 height
Definition: tex.h:217
u8 * data
Definition: tex.h:214
u32 dataSize
Definition: tex.h:215
u32 width
Definition: tex.h:216
void(* MipmapCB)(size_t level, size_t level_w, size_t level_h, const u8 *RESTRICT level_data, size_t level_data_size, void *RESTRICT cbData)
callback function for each mipmap level.
Definition: tex.h:394
bool tex_is_known_extension(const VfsPath &pathname)
Is the file's extension that of a texture format supported by tex_load?
Definition: tex.cpp:565
void tex_set_global_orientation(int orientation)
Set the orientation to which all loaded images will automatically be converted (excepting file format...
Definition: tex.cpp:508
TexFlags
flags describing the pixel format.
Definition: tex.h:141
@ TEX_BGR
indicates B and R pixel components are exchanged.
Definition: tex.h:163
@ TEX_ORIENTATION
Definition: tex.h:192
@ TEX_GREY
indicates the image is 8bpp greyscale.
Definition: tex.h:178
@ TEX_MIPMAPS
mask
Definition: tex.h:199
@ TEX_BOTTOM_UP
flags & TEX_ORIENTATION is a field indicating orientation, i.e.
Definition: tex.h:190
@ TEX_UNDEFINED_FLAGS
Definition: tex.h:201
@ TEX_ALPHA
indicates the image contains an alpha channel.
Definition: tex.h:171
@ DXT1A
we need a special value for DXT1a to avoid having to consider flags & TEX_ALPHA to determine S3TC typ...
Definition: tex.h:156
@ TEX_TOP_DOWN
Definition: tex.h:191
@ TEX_DXT
flags & TEX_DXT is a field indicating compression.
Definition: tex.h:149
const int TEX_BASE_LEVEL_ONLY
special value for levels_to_skip: the callback will only be called for the base mipmap level (i....
Definition: tex.h:382
size_t tex_hdr_size(const VfsPath &filename)
return the minimum header size (i.e.
Definition: tex.cpp:701
void tex_util_foreach_mipmap(size_t w, size_t h, size_t bpp, const u8 *data, int levels_to_skip, size_t data_padding, MipmapCB cb, void *RESTRICT cbData)
for a series of mipmaps stored from base to highest, call back for each level.
Definition: tex.cpp:128
uint8_t u8
Definition: types.h:37
uint32_t u32
Definition: types.h:39