stores all data describing an image.
More...
#include <tex.h>
stores all data describing an image.
we try to minimize size, since this is stored in OglTex resources (which are big and pushing the h_mgr limit).
Status Tex::decode |
( |
const shared_ptr< u8 > & |
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.
encode a texture into a memory buffer in the desired file format.
- Parameters
-
extension | (including '.'). |
da | Output memory array. Allocated here; caller must free it when no longer needed. Invalid unless function succeeds. |
- Returns
- Status
free all resources associated with the image and make further use of it impossible.
- Returns
- Status
u32 Tex::get_average_color |
( |
| ) |
const |
return the ARGB value of the 1x1 mipmap level of the texture.
- Returns
- ARGB value (or 0 if texture does not have mipmaps)
return a pointer to the image data (pixels), taking into account any header(s) that may come before it.
- Returns
- pointer to data returned by mem_get_ptr (holds reference)!
size_t Tex::img_size |
( |
| ) |
const |
return total byte size of the image pixels.
(including mipmaps!) rationale: this is preferable to calculating manually because it's less error-prone (e.g. confusing bits_per_pixel with bytes).
- Returns
- size [bytes]
Status Tex::transform |
( |
size_t |
transforms | ) |
|
Change the pixel format.
- Parameters
-
transforms | TexFlags that are to be flipped. |
- Returns
- Status
Status Tex::transform_to |
( |
size_t |
new_flags | ) |
|
Change the pixel format (2nd version) (note: this is equivalent to Tex::transform(t, t->flags^new_flags).
- Parameters
-
new_flags | desired new value of TexFlags. |
- Returns
- Status
Status Tex::validate |
( |
| ) |
const |
Is the texture object valid and self-consistent?
- Returns
- Status
Status Tex::wrap |
( |
size_t |
w, |
|
|
size_t |
h, |
|
|
size_t |
bpp, |
|
|
size_t |
flags, |
|
|
const 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.
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
shared_ptr<u8> Tex::m_Data |
file buffer or image data.
note: during the course of transforms (which may occur when being loaded), this may be replaced with a new buffer (e.g. if decompressing file contents).
see TexFlags and "Format Conversion" in docs.
offset to image data in file.
this is required since tex_get_data needs to return the pixels, but data returns the actual file buffer. zero-copy load and write-back to file is also made possible.
The documentation for this struct was generated from the following files:
- /var/svn/checkout/source/lib/tex/tex.h
- /var/svn/checkout/source/lib/tex/tex.cpp