Skip to content

API Image Export

dilshan edited this page Nov 22, 2026 · 1 revision

Image Export

Helpers that turn the raw image from olru_read_image into a BMP.

The BMP is an 8 bit palettised bitmap with a 256-entry grey ramp:

14 byte file header | 40 byte DIB header | 1024 byte palette | 73728 pixel bytes

Properties: 256 × 288, 8 bit, bottom-up rows, 500 dpi (19685 pixels per metre), total size OLRU_BMP_SIZE = 74806 bytes. The raw rows are copied unchanged, so the result looks exactly like the BMP written by the vendor SDK.

olru_image_to_bmp

int olru_image_to_bmp(const uint8_t *raw, uint8_t *out, size_t out_size);

Builds a BMP file image in memory.

Parameter Description
raw OLRU_IMAGE_SIZE bytes from olru_read_image
out Buffer that receives the BMP
out_size Size of out; must be at least OLRU_BMP_SIZE

Returns the number of bytes written (always OLRU_BMP_SIZE), or OLRU_ERR_ARG for a NULL pointer or a too-small buffer.

Useful for GUI toolkits that can load an image from memory. For example, with GdkPixbuf:

static uint8_t bmp[OLRU_BMP_SIZE];
if (olru_image_to_bmp(raw, bmp, sizeof bmp) > 0) {
    GdkPixbufLoader *loader = gdk_pixbuf_loader_new();
    gdk_pixbuf_loader_write(loader, bmp, sizeof bmp, NULL);
    gdk_pixbuf_loader_close(loader, NULL);
    GdkPixbuf *pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
    /* use pixbuf, g_object_ref() it if you keep it */
}

olru_image_save_bmp

int olru_image_save_bmp(const uint8_t *raw, const char *path);

Writes the image to a .bmp file (created or overwritten).

Returns OLRU_OK, OLRU_ERR_ARG (NULL argument) or OLRU_ERR_IO (file could not be created or written).

olru_image_save_bmp(image, "finger.bmp");

Other formats

The library intentionally exports only BMP. The raw buffer is plain 8-bit greyscale, so converting to PNG, PGM or a WSQ encoder input is a few lines in your own code or via an image library.

Clone this wiki locally