The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
image.h File Reference

load PNG, JPEG and BMP files into libgfx buffers. More...

#include <gfx.h>

Go to the source code of this file.

Macros

#define IMAGE_MAX_SIDE   8192

Functions

gfx_buffer_t * image_load (const char *path, const char **error)
 load an image file.
gfx_buffer_t * image_decode (const uint8_t *data, size_t size, const char **error)
 decode an image from memory.
int32_t image_inflate (const uint8_t *in, size_t in_size, uint8_t *out, size_t out_size)
 decompress zlib data (RFC 1950) into a buffer of known size.

Detailed Description

load PNG, JPEG and BMP files into libgfx buffers.

the decoder is stb_image (public domain, src/lib/stb). the result is a gfx_buffer_t of premultiplied ARGB; an image without alpha is opaque.

Macro Definition Documentation

◆ IMAGE_MAX_SIDE

#define IMAGE_MAX_SIDE   8192

Function Documentation

◆ image_load()

gfx_buffer_t * image_load ( const char * path,
const char ** error )

load an image file.

Parameters
errorreceives a short reason on failure (may be NULL).
Returns
a new buffer (free it with gfx_buffer_free), or NULL.

◆ image_decode()

gfx_buffer_t * image_decode ( const uint8_t * data,
size_t size,
const char ** error )

decode an image from memory.

◆ image_inflate()

int32_t image_inflate ( const uint8_t * in,
size_t in_size,
uint8_t * out,
size_t out_size )

decompress zlib data (RFC 1950) into a buffer of known size.

Returns
the bytes written, or -1 (bad data, or out does not hold it).