Back to API reference

Image module

Image module is designed to decode (encoding is to be implemented soon) various image formats into raw pixel data also giving out useful metadata. Currently only PNG image format is supported.

First of all, the API is streamed: your create a decoder object, load data from file and get pixels. Pixels are then usually loaded into texture. Pixel data is available as long as it is decoded. So you may update a texture after each data portion received from server by loading freshly decoded pixels.

If image is interlaced, each semi-mipmap is available since decoded. See Adam7 algorithm for details. It's easy to understand why it isn't real mipmap.

Recommended way for progressive loading is to load level 3 image semi-mipmap into level 3 texture mipmap since available, build texture mipmaps from level 3 to higher levels, then load level 2 and level 1 since available. In the end when level 0 mipmap (full image) is available, load it into texture and rebuild all mipmaps.

Real mipmaps could be implemented if future.

Of course you may ignore all that fancy tricks and just wait until an image is completely downloaded, load all the encoded data into decoder, load all pixel data into texture and then build needed mipmaps.

Pixel format

There are 4 pixel channel sets are available:

There are 2 levels of precision per channel (applied for all channels):

The order of channels is direct (no ARGB or ABGR). The order of bytes in 16-bit channel is big endian.

If pixel format is specified, then image is converted to specified pixel format except for one rule: not 16-bit channel image cannot be converted to 16-bit channel. If pixel format is not specified - it is autodetected. In palette color mode 8-bit mode is selected.

See the module reference:

Back to API reference