SOD C/C++ API Reference - Image Processing


sod_img sod_crop_image(sod_img input, int dx, int dy, int w, int h);


Extract a region from a given image.

Input Picture

Nature before processing

Output via sod_crop_image()

Nature after processing


sod_img    input

The input image to be processed. The image can be loaded from disk using sod_img_load_from_file(), from memory (i.e. network socket) via sod_img_load_from_mem() or dynamically created via sod_make_image().

int    dx

The x-coordinate, in logical units of the crop offset.

int    dy

The y-coordinate, in logical units of the crop offset.

int    w

The width of the crop.

int    h

The height of the crop.

Return Value

Cropped image is returned in an instance of the sod_img object. if something goes wrong during processing, 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.


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

See also