/* Function : Cximage_Init Description : The Init function that will be called when the extension is loaded to your tk shell Arguments : Tcl_Interp *interp : This is the interpreter from which the load was made and to which we'll add the new command Return value : TCL_OK in case everything is ok, or TCL_ERROR in case there is an error (Tk version < 8.3) Comments : hummmm... not much, it's simple :) */ int Tkcximage_Init (Tcl_Interp *interp ) { int i; INITLOGS(); // LOG("---------------------------------"); // //Check Tcl version is 8.3 or higher if (Tcl_InitStubs(interp, TCL_VERSION, 1) == NULL) { return TCL_ERROR; } LOG("Tcl stub initialized"); // //Check TK version is 8.3 or higher if (Tk_InitStubs(interp, TK_VERSION, 1) == NULL) { return TCL_ERROR; } LOG("Tk stub initialized"); // LOG("Creating commands"); // // Create the wrapping commands in the CxImage namespace linked to custom functions with a NULL clientdata and // no deleteproc inside the current interpreter Tcl_CreateObjCommand(interp, "::CxImage::Convert", Tk_Convert, (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); Tcl_CreateObjCommand(interp, "::CxImage::Resize", Tk_Resize, (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); Tcl_CreateObjCommand(interp, "::CxImage::Colorize", Tk_Colorize, (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); Tcl_CreateObjCommand(interp, "::CxImage::Thumbnail", Tk_Thumbnail, (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); Tcl_CreateObjCommand(interp, "::CxImage::IsAnimated", Tk_IsAnimated, (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); #if ANIMATE_GIFS Tcl_CreateObjCommand(interp, "::CxImage::StopAnimation", Tk_DisableAnimation, (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); Tcl_CreateObjCommand(interp, "::CxImage::StartAnimation", Tk_EnableAnimation, (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); Tcl_CreateObjCommand(interp, "::CxImage::NumberOfFrames", Tk_NumberOfFrames, (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); Tcl_CreateObjCommand(interp, "::CxImage::JumpToFrame", Tk_JumpToFrame, (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL); if (PlaceHook(interp) != TCL_OK) return TCL_ERROR; #endif LOG("Adding format : "); // for (i = 0; i < AVAILABLE_FORMATS; i++) { Tk_CreatePhotoImageFormat(&cximageFormats[i]); APPENDLOG(cximageFormats[i].name); // } // end of Initialisation return TCL_OK; }
EXTERN void Nap_CreatePhotoImageFormat(void) { Tk_PhotoImageFormat napImgFmtNAO = { "nao", /* name */ NULL, /* fileMatchProc not applicable to NAO's */ StringMatchNAO, /* stringMatchProc */ NULL, /* fileReadProc not applicable to NAO's */ StringReadNAO, /* stringReadProc */ FileWriteNAO, /* fileWriteProc */ NULL /* stringWriteProc not implimented */ }; Tk_CreatePhotoImageFormat(&napImgFmtNAO); }
int cmdInit(Tcl_Interp *interp) { /* Register bwish/btclsh commands */ bu_register_cmds(interp, bwish_cmds); #ifdef BWISH /* Add pix format for images */ Tk_CreatePhotoImageFormat(&tkImgFmtPIX); #endif /* initialize command history */ historyInit(); return TCL_OK; }