CRIMP
Artifact [5973c91b28]
Not logged in

Artifact 5973c91b2867c34f03a3ab27b5b2fc6007e9078f:


setalpha_rgb_grey8
Tcl_Obj* imageObj
Tcl_Obj* imageAlphaObj

/*
 * Extend the input with an alpha channel holding the data of the second
 * image.
 */

crimp_image*     result;
crimp_image*     image;
crimp_image*     imageA;
int x, y;

crimp_input (imageObj,      image,  rgb);
crimp_input (imageAlphaObj, imageA, grey8);

if (!crimp_eq_dim (image, imageA)) {
    Tcl_SetResult(interp, "image dimensions do not match", TCL_STATIC);
    return TCL_ERROR;
}

result = crimp_new_rgba_at (crimp_x (image), crimp_y (image),
			    crimp_w (image), crimp_h (image));

for (y = 0; y < crimp_h (result); y++) {
    for (x = 0; x < crimp_w (result); x++) {
	R (result, x, y) = R (image, x, y);
	G (result, x, y) = G (image, x, y);
	B (result, x, y) = B (image, x, y);
	A (result, x, y) = GREY8 (imageA, x, y);
    }
}

Tcl_SetObjResult(interp, crimp_new_image_obj (result));
return TCL_OK;

/* vim: set sts=4 sw=4 tw=80 et ft=c: */
/*
 * Local Variables:
 * mode: c
 * c-basic-offset: 4
 * fill-column: 78
 * End:
 */