summaryrefslogtreecommitdiff
path: root/im/src/lua5/imlua_image.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_image.c
parent5000908b9b2761854951cea3e7dad90be76ffd59 (diff)
Upgrading im to 3.6
Diffstat (limited to 'im/src/lua5/imlua_image.c')
-rwxr-xr-xim/src/lua5/imlua_image.c46
1 files changed, 42 insertions, 4 deletions
diff --git a/im/src/lua5/imlua_image.c b/im/src/lua5/imlua_image.c
index 55dcc82..0e8676d 100755
--- a/im/src/lua5/imlua_image.c
+++ b/im/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.5 2009/09/25 18:40:31 scuri Exp $
+ * $Id: imlua_image.c,v 1.9 2010/01/17 18:18:12 scuri Exp $
*/
#include <string.h>
@@ -128,6 +128,15 @@ static int imluaImageAddAlpha (lua_State *L)
}
/*****************************************************************************\
+ image:SetAlpha()
+\*****************************************************************************/
+static int imluaImageSetAlpha (lua_State *L)
+{
+ imImageSetAlpha(imlua_checkimage(L, 1), (float)luaL_checknumber(L, 2));
+ return 0;
+}
+
+/*****************************************************************************\
image:Reshape()
\*****************************************************************************/
static int imluaImageReshape (lua_State *L)
@@ -167,6 +176,31 @@ static int imluaImageCopyData (lua_State *L)
}
/*****************************************************************************\
+ image:CopyPlane()
+\*****************************************************************************/
+static int imluaImageCopyPlane(lua_State *L)
+{
+ imImage* src_image = imlua_checkimage(L, 1);
+ int src_plane = luaL_checkint(L, 2);
+ imImage* dst_image = imlua_checkimage(L, 3);
+ int dst_plane = luaL_checkint(L, 4);
+ int src_depth, dst_depth;
+
+ imlua_matchdatatype(L, src_image, dst_image);
+
+ src_depth = src_image->has_alpha? src_image->depth+1: src_image->depth;
+ if (src_plane < 0 || src_plane >= src_depth)
+ luaL_argerror(L, 2, "invalid source channel, out of bounds");
+
+ dst_depth = dst_image->has_alpha? dst_image->depth+1: dst_image->depth;
+ if (dst_plane < 0 || dst_plane >= dst_depth)
+ luaL_argerror(L, 4, "invalid destiny channel, out of bounds");
+
+ imImageCopyPlane(src_image, src_plane, dst_image, dst_plane);
+ return 0;
+}
+
+/*****************************************************************************\
image:Duplicate()
\*****************************************************************************/
static int imluaImageDuplicate (lua_State *L)
@@ -751,13 +785,14 @@ static int imluaImage_tostring (lua_State *L)
if (*image_p)
{
imImage *image = *image_p;
- lua_pushfstring(L, "imImage(%p) [width=%d,height=%d,color_space=%s,data_type=%s,depth=%d]",
+ lua_pushfstring(L, "imImage(%p) [width=%d,height=%d,color_space=%s,data_type=%s,depth=%d,has_alpha=%d]",
image_p,
image->width,
image->height,
imColorModeSpaceName(image->color_space),
imDataTypeName(image->data_type),
- image->depth
+ image->depth,
+ image->has_alpha
);
}
else
@@ -956,7 +991,8 @@ static int imluaImage_index (lua_State *L)
int channel = luaL_checkint(L, 2);
/* create channel */
- if (channel < 0 || channel >= image->depth)
+ int depth = image->has_alpha? image->depth+1: image->depth;
+ if (channel < 0 || channel >= depth)
luaL_argerror(L, 2, "invalid channel, out of bounds");
imlua_newimagechannel(L, image, channel);
@@ -989,9 +1025,11 @@ static const luaL_reg imimage_lib[] = {
static const luaL_reg imimage_metalib[] = {
{"Destroy", imluaImageDestroy},
{"AddAlpha", imluaImageAddAlpha},
+ {"SetAlpha", imluaImageSetAlpha},
{"Reshape", imluaImageReshape},
{"Copy", imluaImageCopy},
{"CopyData", imluaImageCopyData},
+ {"CopyPlane", imluaImageCopyPlane},
{"Duplicate", imluaImageDuplicate},
{"Clone", imluaImageClone},
{"SetAttribute", imluaImageSetAttribute},