typedef struct xlg_matrix_struct {
...;
const char *name, *desc;
int sx, sy, sz;
const double *table;
double divisor, bias;
int show;
} XLG_matrix;
Base definition. .sx, .sy and .sz are the dimensions of the in-fact one-dimensional .table array. It does not need to be const per se (like any input to i.e. strcmp() also does not need).
.divisor specifies a kind of pre-squashing. It is good for the case when the destination pixel's RGB range implies values >255. The formula is dest /= divisor; (so use divisor=0.5 to multiply by 2).
.bias specifies a value to be added after division. [At the moment,] the value is in the 256' space, which means that you need to add 128 rather than 0.5. (If you do not know what I am talking about bias here, skip it.)
int xlg_mx_register(XLG_filter *);
int xlg_mx_unregister(XLG_filter *);
(Un)registers a matrix within the internal database. This is really only needed by base/matrix.c itself.
Adding a new matrix to libxlg (that is, libxlg itself, not your application) requires its manual registration in the matrix.c source file.
A matrix does not need to be registered to be used.
int xlg_mx_list(XLG_matrix ***p);
xlg_mx_list() returns a list of available and matrices. The list is allocated with malloc() and is stored in *p (so you have to free(*p), only). The number of available matrices is returned. If there are no matrices currently registered, nothing is allocated and 0 is returned. Also, nothing is done upon error, in which case -errno is returned.
Applications may NOT rely on .Next, since this is only an internal field for the xlg_mx code.
XLG_matrix *xlg_mx_get(const char *name);
Returns the XLG_matrix structure for a given matrix. Returns NULL if no such matrix was found in the list.