summaryrefslogtreecommitdiff
path: root/im/src/lua5/imlua_process.c
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2010-06-14 23:47:31 -0700
committerPixel <pixel@nobis-crew.org>2010-06-14 23:47:31 -0700
commit7c0c85a86aa73c0c495523f994f8412e377a8195 (patch)
tree29929fdc4390224b3a4f8b728d50ae5dfc3589ce /im/src/lua5/imlua_process.c
parent5000908b9b2761854951cea3e7dad90be76ffd59 (diff)
Upgrading im to 3.6
Diffstat (limited to 'im/src/lua5/imlua_process.c')
-rwxr-xr-xim/src/lua5/imlua_process.c41
1 files changed, 30 insertions, 11 deletions
diff --git a/im/src/lua5/imlua_process.c b/im/src/lua5/imlua_process.c
index 38d39e9..978428b 100755
--- a/im/src/lua5/imlua_process.c
+++ b/im/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.8 2009/10/01 02:56:58 scuri Exp $
+ * $Id: imlua_process.c,v 1.11 2010/03/21 22:29:10 scuri Exp $
*/
#include <memory.h>
@@ -1703,6 +1703,22 @@ static int imluaProcessBlend (lua_State *L)
}
/*****************************************************************************\
+ im.ProcessCompose
+\*****************************************************************************/
+static int imluaProcessCompose(lua_State *L)
+{
+ imImage *src_image1 = imlua_checkimage(L, 1);
+ imImage *src_image2 = imlua_checkimage(L, 2);
+ imImage *dst_image = imlua_checkimage(L, 3);
+
+ imlua_match(L, src_image1, src_image2);
+ imlua_match(L, src_image1, dst_image);
+
+ imProcessCompose(src_image1, src_image2, dst_image);
+ return 0;
+}
+
+/*****************************************************************************\
im.ProcessSplitComplex
\*****************************************************************************/
static int imluaProcessSplitComplex (lua_State *L)
@@ -2009,18 +2025,19 @@ static int imluaProcessMergeHSI (lua_State *L)
\*****************************************************************************/
static int imluaProcessSplitComponents (lua_State *L)
{
- int i;
+ int i, src_depth;
imImage *src_image = imlua_checkimage(L, 1);
imImage **dst_image_list;
luaL_checktype(L, 2, LUA_TTABLE);
- if (imlua_getn(L, 2) != src_image->depth)
+ src_depth = src_image->has_alpha? src_image->depth+1: src_image->depth;
+ if (imlua_getn(L, 2) != src_depth)
luaL_error(L, "number of destiny images must match the depth of the source image");
- dst_image_list = (imImage**)malloc(sizeof(imImage*)*src_image->depth);
+ dst_image_list = (imImage**)malloc(sizeof(imImage*)*src_depth);
- for (i = 0; i < src_image->depth; i++)
+ for (i = 0; i < src_depth; i++)
{
lua_pushnumber(L, i+1);
lua_gettable(L, 2);
@@ -2029,7 +2046,7 @@ static int imluaProcessSplitComponents (lua_State *L)
lua_pop(L, 1);
}
- for (i = 0; i < src_image->depth; i++)
+ for (i = 0; i < src_depth; i++)
{
int check = imImageMatchDataType(src_image, dst_image_list[i]);
if (!check) free(dst_image_list);
@@ -2048,19 +2065,20 @@ static int imluaProcessSplitComponents (lua_State *L)
\*****************************************************************************/
static int imluaProcessMergeComponents (lua_State *L)
{
- int i;
+ int i, dst_depth;
imImage** src_image_list;
imImage *dst_image;
luaL_checktype(L, 1, LUA_TTABLE);
dst_image = imlua_checkimage(L, 2);
- if (imlua_getn(L, 1) != dst_image->depth)
+ dst_depth = dst_image->has_alpha? dst_image->depth+1: dst_image->depth;
+ if (imlua_getn(L, 1) != dst_depth)
luaL_error(L, "number of source images must match the depth of the destination image");
- src_image_list = (imImage**)malloc(sizeof(imImage*)*dst_image->depth);
+ src_image_list = (imImage**)malloc(sizeof(imImage*)*dst_depth);
- for (i = 0; i < dst_image->depth; i++)
+ for (i = 0; i < dst_depth; i++)
{
lua_pushnumber(L, i+1);
lua_gettable(L, 1);
@@ -2069,7 +2087,7 @@ static int imluaProcessMergeComponents (lua_State *L)
lua_pop(L, 1);
}
- for (i = 0; i < dst_image->depth; i++)
+ for (i = 0; i < dst_depth; i++)
{
int check = imImageMatchDataType(src_image_list[i], dst_image);
if (!check) free(src_image_list);
@@ -2988,6 +3006,7 @@ static const luaL_reg improcess_lib[] = {
{"ProcessArithmeticConstOp", imluaProcessArithmeticConstOp},
{"ProcessBlendConst", imluaProcessBlendConst},
{"ProcessBlend", imluaProcessBlend},
+ {"ProcessCompose", imluaProcessCompose},
{"ProcessSplitComplex", imluaProcessSplitComplex},
{"ProcessMergeComplex", imluaProcessMergeComplex},
{"ProcessMultipleMean", imluaProcessMultipleMean},