SOD C/C++ API Reference - Image Processing


Syntax

sod_img sod_img_load_from_mem(const unsigned char *zBuf, int buf_len, int nChannels);

Description

Load an image from memory. On success, a memory representation of the target image is returned in an instance of the sod_img object which can be processed or analyzed via the exported interfaces. As of this release, the following image format are officially supported: JPEG, PNG, BMP, HDR, PSD, TGA, PIC, PPM, PGM, PBM. If you want to load an image from disk, take a look at sod_img_load_from_file() or sod_img_set_load_from_directory().

Parameters

const unsigned char    *zBuf

Memory buffer holding the raw image.

int    buf_len

Size of the memory buffer.

int    nChannels

Total number of color channels to load. Set this parameter to 0 for the default behavior. 1 for grayscale colorspace conversion or 3 for full color channels.

Return Value

Memory representation of the target image is returned in an instance of the sod_img object. if something goes wrong during loading (i.e. Unsupported format or running out-of-memory), then an empty image is returned via sod_make_empty_image(). Once done, you must release the memory allocated to this object via sod_free_image() to avoid memory leaks.

Example

Checkout the introduction course, the C/C++ samples on the download page or refer to the SOD Github Repository.

See also

sod_canny_edge_imagesod_image_draw_boxsod_hilditch_thinsod_hough_lines_detectsod_crop_imagesod_resize_image.



Back