`lqr_carver_new`
Prev | Carver objects | Next

## Name

lqr_carver_new, lqr_carver_new_ext — the `LqrCarver` object constructors

## Synopsis

    #include <lqr.h>

`LqrCarver* lqr_carver_new(` | guchar* buffer,
| gint width,
| gint height,
| gint channels`)`;

`LqrCarver* lqr_carver_new_ext(` | void* buffer,
| gint width,
| gint height,
| gint channels,
| LqrColDepth colour_depth`)`;

## Description

The functions `lqr_carver_new` and `lqr_carver_new_ext` create a new `LqrCarver` object from an image of size `width` * `height` with `channels` colour channels.

The image must be stored in `buffer` as a plain array of unsigned chars (for `lqr_carver_new`) or the appropriate type cast to void (for `lqr_carver_new_ext`), ordered by row, then by column, then by colour channel.

In the extended constructor `lqr_carver_new_ext`, the additional parameter `colour_depth` is required to specify the colour depth of the buffer (see LqrColDepth(3) for more information).

After calling the function, the buffer will be owned by the `LqrCarver` object and must not be accessed any more, unless you subsequently call the `lqr_carver_set_preserve_input_image`(3) function.

The image type is et automatically from the value of `channels` according to this table:

Table 3.1. Image types assigned by default

channels | type
--- | ---
1 | `LQR_GREY_IMAGE`
2 | `LQR_GREYA_IMAGE`
3 | `LQR_RGB_IMAGE`
4 | `LQR_RGBA_IMAGE`
5 | `LQR_CMYKA_IMAGE`
>5 | `LQR_CUSTOM_IMAGE`

## Return value

The return value is the address of the newly created `LqrCarver` object, or `NULL` in case of failure (insufficient memory).

## See also

LqrColDepth(3), LqrImageType(3), `lqr_carver_destroy`(3), `lqr_carver_init`(3), `lqr_carver_set_preserve_input_image`(3)

Prev | Up | Next
Carver objects | Home | `lqr_carver_destroy`