|
| | ~Tex () |
| |
| Status | validate () const |
| | Is the texture object valid and self-consistent? More...
|
| |
| void | free () |
| | free all resources associated with the image and make further use of it impossible. More...
|
| |
| Status | decode (const std::shared_ptr< std::uint8_t > &data, size_t data_size) |
| | decode an in-memory texture file into texture object. More...
|
| |
| Status | encode (const OsPath &extension, DynArray *da) |
| | encode a texture into a memory buffer in the desired file format. More...
|
| |
| Status | wrap (size_t w, size_t h, size_t bpp, size_t flags, const std::shared_ptr< std::uint8_t > &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. More...
|
| |
| Status | transform (size_t transforms) |
| | Change the pixel format. More...
|
| |
| Status | transform_to (size_t new_flags) |
| | Change the pixel format (2nd version) (note: this is equivalent to Tex::transform(t, t->flags^new_flags). More...
|
| |
| std::uint8_t * | get_data () |
| | return a pointer to the image data (pixels), taking into account any header(s) that may come before it. More...
|
| |
| const std::vector< MIPLevel > & | GetMIPLevels () const |
| |
| std::uint32_t | get_average_color () const |
| | return the ARGB value of the 1x1 mipmap level of the texture. More...
|
| |
| size_t | img_size () const |
| | return total byte size of the image pixels. More...
|
| |
Stores all data describing an image.
TODO: rename to TextureData.
| Status Tex::decode |
( |
const std::shared_ptr< std::uint8_t > & |
data, |
|
|
size_t |
data_size |
|
) |
| |
decode an in-memory texture file into texture object.
FYI, currently BMP, TGA, JPG, JP2, PNG, DDS are supported - but don't rely on this (not all codecs may be included).
- Parameters
-
| data | Input data. |
| data_size | Its size [bytes]. |
- Returns
- Status.
| Status Tex::wrap |
( |
size_t |
w, |
|
|
size_t |
h, |
|
|
size_t |
bpp, |
|
|
size_t |
flags, |
|
|
const std::shared_ptr< std::uint8_t > & |
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.
rationale: support for in-memory images is necessary for emulation of glCompressedTexImage2D and useful overall. however, we don't want to provide an alternate interface for each API; these would have to be changed whenever fields are added to Tex. instead, provide one entry point for specifying images. note: since we do not know how <img> was allocated, the caller must free it themselves (after calling tex_free, which is required regardless of alloc type).
we need only add bookkeeping information and "wrap" it in our Tex struct, hence the name.
- Parameters
-
| w,h | Pixel dimensions. |
| bpp | Bits per pixel. |
| flags | TexFlags. |
| data | Img texture data. note: size is calculated from other params. |
| ofs | |
- Returns
- Status