/*****************************************************************************\ image:Clone() \*****************************************************************************/ static int imluaImageClone (lua_State *L) { imImage* image = imlua_checkimage(L, 1); imImage *new_image = imImageClone(image); imlua_pushimage(L, new_image); return 1; }
static int GetNativeHandleImage(lua_State *L) { void* native_handle; imImage* im_image; luaL_checktype (L, 1, LUA_TLIGHTUSERDATA); native_handle = lua_touserdata(L, 1); im_image = IupGetNativeHandleImage(native_handle); imlua_pushimage(L, im_image); return 1; }
/*****************************************************************************\ im.ImageCreateFromOpenGLData(width, height, glformat, gldata) \*****************************************************************************/ static int imluaImageCreateFromOpenGLData (lua_State *L) { int width = luaL_checkint(L, 1); int height = luaL_checkint(L, 2); int glformat = luaL_checkint(L, 3); void* gldata = lua_touserdata(L, 4); imImage *image = imImageCreateFromOpenGLData(width, height, glformat, gldata); imlua_pushimage(L, image); return 1; }
int imlua_pushimageerror(lua_State *L, imImage* image, int error) { if (error) { lua_pushnil(L); /* one for the image */ imlua_pusherror(L, error); /* one for the error */ return 2; } else { imlua_pushimage(L, image); return 1; /* the error will be nil */ } }
/*****************************************************************************\ im.ImageCreate(width, height, color_space, data_type) \*****************************************************************************/ static int imluaImageCreate (lua_State *L) { int width = luaL_checkint(L, 1); int height = luaL_checkint(L, 2); int color_space = luaL_checkint(L, 3); int data_type = luaL_checkint(L, 4); imImage *image; if (!imImageCheckFormat(color_space, data_type)) luaL_error(L, "invalid combination of color space and data type."); image = imImageCreate(width, height, color_space, data_type); imlua_pushimage(L, image); return 1; }