blob: 10a2eda6cb8ca950d7fb5c8efa0cb783f93c164f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/** \file
* \brief IULUA core - Bindig of iup to Lua 5.
*
* See Copyright Notice in "iup.h"
*/
#include "iup.h"
#include "iupim.h"
#include <lua.h>
#include <lauxlib.h>
#include "iuplua.h"
#include "iupluaim.h"
#include "il.h"
static int SaveImage(lua_State *L)
{
Ihandle *image = iuplua_checkihandle(L,1);
const char *filename = luaL_checkstring(L, 2);
const char *format = luaL_checkstring(L, 3);
lua_pushboolean(L, IupSaveImage(image, filename, format));
return 1;
}
static int LoadImage(lua_State *L)
{
const char *filename = luaL_checkstring(L, 1);
Ihandle* image = IupLoadImage(filename);
iuplua_plugstate(L, image);
iuplua_pushihandle(L, image);
return 1;
}
int iupimlua_open(lua_State *L)
{
iuplua_get_env(L);
iuplua_register(L, LoadImage, "LoadImage");
iuplua_register(L, SaveImage, "SaveImage");
return 0; /* nothing in stack */
}
/* obligatory to use require"iupluaim" */
int luaopen_iupluaim(lua_State* L)
{
return iupimlua_open(L);
}
|