The open imaging DSP library
Loading...
Searching...
No Matches
How to do resize an image

Use libmpix to downscale/upscale an image.

Resizing an image an image can be done according to several strategies with trade-offs betwen speed and quality of the result.

In case the resizing strategy you wished to use (such as blending) is not available, then let us know.

How to resize images in libmpix

First load a buffer into an image struct, specifying any supported pixel 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

Then choose the type of resize operation you wish to use:

  • MPIX_RESIZE_SUBSAMPLING which can take any resolution but lower quality,

Then apply the resize operation using the selected strategy:

mpix_image_resize(&img, MPIX_RESIZE_SUBSAMPLING);

See Supported operations for the list of all supported resize types for each format.