The open imaging DSP library
Loading...
Searching...
No Matches
How to QOI-encode images

Uses libmpix to encode image to the QOI format.

The Quite Ok Image Format (QOI Format) a lossless compression codec with ratios close to PNG at a fraction of the complexity. This makes it a good candidate for use in low-power platforms such as microcontrollers.

How to encode QOI images with libmpix

First load a buffer into an image struct, in RGB format:

struct mpix_image img;
struct mpix_format fmt = { .width = 640, .height = 480, .fourcc = MPIX_FMT_RGB24 };
mpix_image_from_buf(&img, buf, sizeof(buf), &fmt);
#define MPIX_FMT_RGB24
Definition formats.h:125
static void mpix_image_from_buf(struct mpix_image *img, const uint8_t *buffer, size_t size, const struct mpix_format *fmt)
Initialize an image from a memory buffer.
Definition image.h:30
Image format description.
Definition types.h:72
uint16_t width
Definition types.h:76
Represent the image currently being processed.
Definition types.h:136

If the image is not in RGB format, you may then need ot add an extra format conversion step (How to convert pixel formats).

Then encode the image to the QOI format:

static int mpix_image_qoi_encode(struct mpix_image *img)
Encode an image to the QOI compressed image format.
Definition image.h:204