write_rgb_tk
char* photo Tcl_Obj* imageObj
Tk_PhotoHandle handle = Tk_FindPhoto(interp, photo);
Tk_PhotoImageBlock pib;
crimp_image* image;
if (!handle) {
Tcl_ResetResult (interp);
Tcl_AppendResult(interp, "image \"", photo, "\" doesn't exist", NULL);
return TCL_ERROR;
}
crimp_input (imageObj, image, rgb);
/*
* Fill the Tk image block to match our structure.
*/
pib.pixelPtr = image->pixel;
pib.width = image->w;
pib.height = image->h;
pib.pixelSize = 3;
pib.pitch = 3 * pib.width;
pib.offset[0] = 0;
pib.offset[1] = 1;
pib.offset[2] = 2;
pib.offset[3] = 0;
/*
* ... and push into the destination tk photo
*/
if (Tk_PhotoSetSize (interp, handle, pib.width, pib.height) != TCL_OK ||
Tk_PhotoPutBlock(interp, handle, &pib, 0, 0, pib.width, pib.height,
TK_PHOTO_COMPOSITE_SET) != TCL_OK) {
return TCL_ERROR;
}
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:
*/