summaryrefslogtreecommitdiff
path: root/iup/srclua5/iuplua_im.c
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2009-11-04 11:56:41 -0800
committerPixel <pixel@nobis-crew.org>2009-11-04 11:59:33 -0800
commitd577d991b97ae2b5ee1af23641bcffc3f83af5b2 (patch)
tree590639d50205d1bcfaff2a7d2dc6ebf3f373c7ed /iup/srclua5/iuplua_im.c
Initial import. Contains the im, cd and iup librairies, and a "working" Makefile for them under linux.
Diffstat (limited to 'iup/srclua5/iuplua_im.c')
-rwxr-xr-xiup/srclua5/iuplua_im.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/iup/srclua5/iuplua_im.c b/iup/srclua5/iuplua_im.c
new file mode 100755
index 0000000..b700e1a
--- /dev/null
+++ b/iup/srclua5/iuplua_im.c
@@ -0,0 +1,54 @@
+/** \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_changeEnv(L);
+ iuplua_register(L, LoadImage, "LoadImage");
+ iuplua_register(L, SaveImage, "SaveImage");
+ iuplua_returnEnv(L);
+ return 0; /* nothing in stack */
+}
+
+/* obligatory to use require"iupluaim" */
+int luaopen_iupluaim(lua_State* L)
+{
+ return iupimlua_open(L);
+}
+
+/* obligatory to use require"iupluaim51" */
+int luaopen_iupluaim51(lua_State* L)
+{
+ return iupimlua_open(L);
+}