From 6a8ef4952936e5bd018b2b595a3fd1bb40fbb103 Mon Sep 17 00:00:00 2001 From: scuri Date: Wed, 12 Aug 2009 04:08:57 +0000 Subject: *** empty log message *** --- src/lua5/imlua_capture.c | 58 +++++++++++++++++++++++++++++++++--------------- src/lua5/imlua_image.c | 35 ++++++++++++++++++++++++++++- src/lua5/imlua_process.c | 8 +++---- 3 files changed, 78 insertions(+), 23 deletions(-) (limited to 'src/lua5') diff --git a/src/lua5/imlua_capture.c b/src/lua5/imlua_capture.c index 15d52ce..59ec0fb 100644 --- a/src/lua5/imlua_capture.c +++ b/src/lua5/imlua_capture.c @@ -2,7 +2,7 @@ * \brief IM Lua 5 Binding * * See Copyright Notice in im_lib.h - * $Id: imlua_capture.c,v 1.1 2008/10/17 06:16:32 scuri Exp $ + * $Id: imlua_capture.c,v 1.2 2009/08/12 04:09:17 scuri Exp $ */ #include @@ -92,7 +92,10 @@ static int imluaVideoCaptureConnect (lua_State *L) { imVideoCapture *vc = imlua_checkvideocapture(L, 1); int device = luaL_optint(L, 2, -1); - lua_pushnumber(L, imVideoCaptureConnect(vc, device)); + if (device == -1) + lua_pushnumber(L, imVideoCaptureConnect(vc, device)); + else + lua_pushboolean(L, imVideoCaptureConnect(vc, device)); return 1; } @@ -123,7 +126,7 @@ static int imluaVideoCaptureShowDialog (lua_State *L) int dialog = luaL_checkint(L, 2); void *parent = lua_touserdata(L, 3); - lua_pushnumber(L, imVideoCaptureShowDialog(vc, dialog, parent)); + lua_pushboolean(L, imVideoCaptureShowDialog(vc, dialog, parent)); return 1; } @@ -158,7 +161,7 @@ static int imluaVideoCaptureGetFormat (lua_State *L) int width, height; char desc[10]; - lua_pushnumber(L, imVideoCaptureGetFormat(vc, format, &width, &height, desc)); + lua_pushboolean(L, imVideoCaptureGetFormat(vc, format, &width, &height, desc)); lua_pushnumber(L, width); lua_pushnumber(L, height); lua_pushstring(L, desc); @@ -190,24 +193,40 @@ static int imluaVideoCaptureSetImageSize (lua_State *L) int width = luaL_checkint(L, 2); int height = luaL_checkint(L, 3); - lua_pushnumber(L, imVideoCaptureSetImageSize(vc, width, height)); + lua_pushboolean(L, imVideoCaptureSetImageSize(vc, width, height)); return 1; } /*****************************************************************************\ - vc:SetFormat() + vc:SetInOut() \*****************************************************************************/ -static int imluaVideoCaptureSetFormat (lua_State *L) +static int imluaVideoCaptureSetInOut(lua_State *L) { imVideoCapture *vc = imlua_checkvideocapture(L, 1); - int format = luaL_checkint(L, 2); + int input = luaL_checkint(L, 2); + int output = luaL_checkint(L, 3); + int cross = luaL_checkint(L, 4); - lua_pushnumber(L, imVideoCaptureSetFormat(vc, format)); + lua_pushboolean(L, imVideoCaptureSetInOut(vc, input, output, cross)); return 1; } +/*****************************************************************************\ + vc:SetFormat() +\*****************************************************************************/ +static int imluaVideoCaptureSetFormat (lua_State *L) +{ + imVideoCapture *vc = imlua_checkvideocapture(L, 1); + int format = luaL_optint(L, 2, -1); + if (format == -1) + lua_pushnumber(L, imVideoCaptureSetFormat(vc, format)); + else + lua_pushboolean(L, imVideoCaptureSetFormat(vc, format)); + return 1; +} + /*****************************************************************************\ vc:ResetAttribute(attrib, fauto) \*****************************************************************************/ @@ -215,9 +234,9 @@ static int imluaVideoCaptureResetAttribute (lua_State *L) { imVideoCapture *vc = imlua_checkvideocapture(L, 1); const char *attrib = luaL_checkstring(L, 2); - int fauto = luaL_checkint(L, 3); + int fauto = lua_toboolean(L, 3); - lua_pushnumber(L, imVideoCaptureResetAttribute(vc, attrib, fauto)); + lua_pushboolean(L, imVideoCaptureResetAttribute(vc, attrib, fauto)); return 1; } @@ -230,7 +249,7 @@ static int imluaVideoCaptureSetAttribute (lua_State *L) const char *attrib = luaL_checkstring(L, 2); float percent = (float) luaL_checknumber(L, 3); - lua_pushnumber(L, imVideoCaptureSetAttribute(vc, attrib, percent)); + lua_pushboolean(L, imVideoCaptureSetAttribute(vc, attrib, percent)); return 1; } @@ -243,7 +262,7 @@ static int imluaVideoCaptureGetAttribute (lua_State *L) const char *attrib = luaL_checkstring(L, 2); float percent; - lua_pushnumber(L, imVideoCaptureGetAttribute(vc, attrib, &percent)); + lua_pushboolean(L, imVideoCaptureGetAttribute(vc, attrib, &percent)); lua_pushnumber(L, percent); return 2; } @@ -282,7 +301,7 @@ static int imluaVideoCaptureFrame (lua_State *L) luaL_argerror(L, 2, "image must be of RGB or Gray color spaces"); imlua_checkdatatype(L, 2, image, IM_BYTE); - lua_pushnumber(L, imVideoCaptureFrame(vc, image->data[0], image->color_space, timeout)); + lua_pushboolean(L, imVideoCaptureFrame(vc, image->data[0], image->color_space, timeout)); return 1; } @@ -299,7 +318,7 @@ static int imluaVideoCaptureOneFrame (lua_State *L) luaL_argerror(L, 2, "image must be of RGB or Gray color spaces"); imlua_checkdatatype(L, 2, image, IM_BYTE); - lua_pushnumber(L, imVideoCaptureOneFrame(vc, image->data[0], image->color_space)); + lua_pushboolean(L, imVideoCaptureOneFrame(vc, image->data[0], image->color_space)); return 1; } @@ -310,9 +329,11 @@ static int imluaVideoCaptureOneFrame (lua_State *L) static int imluaVideoCaptureLive (lua_State *L) { imVideoCapture *vc = imlua_checkvideocapture(L, 1); - int live = luaL_checkint(L, 2); - - lua_pushnumber(L, imVideoCaptureLive(vc, live)); + int live = luaL_optint(L, 2, -1); + if (live == -1) + lua_pushnumber(L, imVideoCaptureLive(vc, live)); + else + lua_pushboolean(L, imVideoCaptureLive(vc, live)); return 1; } @@ -377,6 +398,7 @@ static const luaL_reg imcapture_metalib[] = { {"SetFormat", imluaVideoCaptureSetFormat}, {"GetImageSize", imluaVideoCaptureGetImageSize}, {"SetImageSize", imluaVideoCaptureSetImageSize}, + {"SetInOut", imluaVideoCaptureSetInOut}, {"ResetAttribute", imluaVideoCaptureResetAttribute}, {"GetAttribute", imluaVideoCaptureGetAttribute}, {"SetAttribute", imluaVideoCaptureSetAttribute}, diff --git a/src/lua5/imlua_image.c b/src/lua5/imlua_image.c index 22ed38c..dc3322a 100644 --- a/src/lua5/imlua_image.c +++ b/src/lua5/imlua_image.c @@ -2,7 +2,7 @@ * \brief IM Lua 5 Binding * * See Copyright Notice in im_lib.h - * $Id: imlua_image.c,v 1.1 2008/10/17 06:16:32 scuri Exp $ + * $Id: imlua_image.c,v 1.2 2009/08/12 04:09:17 scuri Exp $ */ #include @@ -437,6 +437,28 @@ static int imluaImageIsBitmap (lua_State *L) return 1; } + +/*****************************************************************************\ + image:GetOpenGLData() +\*****************************************************************************/ +static int imluaImageGetOpenGLData (lua_State *L) +{ + int format; + imbyte* gldata; + imImage *image = imlua_checkimage(L, 1); + + gldata = imImageGetOpenGLData(image, &format); + if (!gldata) + { + lua_pushnil(L); + return 1; + } + + lua_pushlightuserdata(L, gldata); + lua_pushinteger(L, format); + return 2; +} + /*****************************************************************************\ image:GetPalette() \*****************************************************************************/ @@ -550,6 +572,15 @@ static int imluaImageMakeBinary (lua_State *L) return 0; } +/*****************************************************************************\ + image:MakeGray() +\*****************************************************************************/ +static int imluaImageMakeGray (lua_State *L) +{ + imImageMakeGray(imlua_checkimage(L, 1)); + return 0; +} + /*****************************************************************************\ image:Width() \*****************************************************************************/ @@ -965,6 +996,7 @@ static const luaL_reg imimage_metalib[] = { {"GetAttributeList", imluaImageGetAttributeList}, {"Clear", imluaImageClear}, {"IsBitmap", imluaImageIsBitmap}, + {"GetOpenGLData", imluaImageGetOpenGLData}, {"SetPalette", imluaImageSetPalette}, {"GetPalette", imluaImageGetPalette}, {"CopyAttributes", imluaImageCopyAttributes}, @@ -975,6 +1007,7 @@ static const luaL_reg imimage_metalib[] = { {"Match", imluaImageMatch}, {"SetBinary", imluaImageSetBinary}, {"MakeBinary", imluaImageMakeBinary}, + {"MakeGray", imluaImageMakeGray}, {"Width", imluaImageWidth}, {"Height", imluaImageHeight}, {"Depth", imluaImageDepth}, diff --git a/src/lua5/imlua_process.c b/src/lua5/imlua_process.c index 492a1ba..1c0dfc8 100644 --- a/src/lua5/imlua_process.c +++ b/src/lua5/imlua_process.c @@ -2,7 +2,7 @@ * \brief IM Lua 5 Binding * * See Copyright Notice in im_lib.h - * $Id: imlua_process.c,v 1.5 2009/08/04 21:35:26 scuri Exp $ + * $Id: imlua_process.c,v 1.6 2009/08/12 04:09:17 scuri Exp $ */ #include @@ -77,7 +77,7 @@ static int imluaCalcHistogram (lua_State *L) { imImage* src_image = imlua_checkimage(L, 1); int plane = luaL_checkint(L, 2); - int cumulative = luaL_checkint(L, 3); + int cumulative = lua_toboolean(L, 3); switch (src_image->data_type) { @@ -112,7 +112,7 @@ static int imluaCalcGrayHistogram (lua_State *L) { unsigned long hist[256]; imImage* src_image = imlua_checkimage(L, 1); - int cumulative = luaL_checkint(L, 2); + int cumulative = lua_toboolean(L, 2); imlua_checkdatatype(L, 1, src_image, IM_BYTE); if (src_image->color_space >= IM_CMYK) @@ -1679,7 +1679,7 @@ static int imluaProcessMergeComplex (lua_State *L) imImage *src_image1 = imlua_checkimage(L, 1); imImage *src_image2 = imlua_checkimage(L, 2); imImage *dst_image = imlua_checkimage(L, 3); - int polar = luaL_checkint(L, 5); + int polar = lua_toboolean(L, 4); imlua_checkdatatype(L, 1, src_image1, IM_FLOAT); imlua_checkdatatype(L, 2, src_image2, IM_FLOAT); -- cgit v1.2.3