summaryrefslogtreecommitdiff
path: root/src/lua5/imlua_image.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua5/imlua_image.c')
-rw-r--r--src/lua5/imlua_image.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/lua5/imlua_image.c b/src/lua5/imlua_image.c
index 32a3080..dcb1647 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.6 2009/12/25 22:43:50 scuri Exp $
+ * $Id: imlua_image.c,v 1.7 2010/01/06 20:16:29 scuri Exp $
*/
#include <string.h>
@@ -175,13 +175,16 @@ static int imluaImageCopyPlane(lua_State *L)
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_match(L, src_image, dst_image);
- if (src_plane < 0 || src_plane >= src_image->depth)
+ 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");
- if (dst_plane < 0 || dst_plane >= dst_image->depth)
+ 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);
@@ -773,13 +776,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
@@ -978,7 +982,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);