![]() |
![]() |
![]() |
![]() |
Information describing an image
#include <img.h>
typedef struct {
union {
struct {
uint8 *data;
unsigned stride;
} direct;
struct {
img_access_f *access_f;
Uintptrt data;
} indirect;
} access;
unsigned w, h;
img_format_t format;
unsigned npalette;
img_color_t *palette;
unsigned flags;
union {
uint8 index;
uint16 rgb16;
img_color_t rgb32;
} transparency;
unsigned quality;
} img_t;
The img_t structure describes a decoded frame. The members include:
Using the direct access model, anyone operating on the image data can access it directly via a pointer. The beginning of the image data is pointed to by direct.data, and it is assumed that the data pointed to is a contiguous buffer of h scanlines of direct.stride bytes each.
![]() |
The stride can be much larger (if needed) than the actual number of bytes required to represent a single scanline in the specified format; anyone operating on the image should never overwrite or otherwise give any regard to the “in between” padding bytes. |
Using the indirect access model, anyone operating on the image data does it through a function; the function pointer is given by indirect.access_f, and indirect.data provides a facility to give your access function some context.
An access function is a function you provide to read or write a run of pixels to or from your image. An access function must be coded either as a reader or writer, there is no way to tell from the parameters the direction of data flow.
void access_f(uintptr_t data, unsigned x,
unsigned y, unsigned n, uint8_t *pixels)
![]() |
The format of the data in pixels will be the same as the format of the image; that is, no data transformation is required at this level. The x, y, and n arguments are guaranteed not to exceed the boundary of your image so you don't have to check for that. |
Image library
img_decode_callouts_t(), img_decode_frame(), img_decode_validate(), img_load_file()
![]() |
![]() |
![]() |
![]() |