From f7cb3c864a65132c672da90a81627e49c98a1ca9 Mon Sep 17 00:00:00 2001
From: scuri
Date: Wed, 6 Jan 2010 20:15:34 +0000
Subject: *** empty log message ***
---
html/en/copyright.html | 2 +-
html/en/history.html | 8 +++++++-
src/lua5/imlua_image.c | 17 +++++++++++------
src/lua5/imlua_process.c | 24 +++++++++++++-----------
src/process/im_color.cpp | 6 +++---
5 files changed, 35 insertions(+), 22 deletions(-)
diff --git a/html/en/copyright.html b/html/en/copyright.html
index de91c03..4bfb681 100644
--- a/html/en/copyright.html
+++ b/html/en/copyright.html
@@ -25,7 +25,7 @@ a Tecgraf logo and a link to our site in a web page for your product.
from licensed software. The library was developed by request of Petrobras. Petrobras permits Tecgraf to distribute the
library under the conditions here presented.
-Copyright © 1994-2009 Tecgraf, PUC-Rio.
+Copyright © 1994-2010 Tecgraf, PUC-Rio.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
diff --git a/html/en/history.html b/html/en/history.html
index 47bd86d..38ec86a 100644
--- a/html/en/history.html
+++ b/html/en/history.html
@@ -12,7 +12,7 @@
History of Changes
- CVS (25/Dec/2009)
+ CVS (04/Jan/2010)
- New: function
imImageCopyPlane.
@@ -24,6 +24,12 @@
imAnalyzeFindRegions when more than 16k regions where found.
- Fixed: memory leak in imFileOpen.
+ - Fixed: alpha support in
+ imProcessSplitComponents and imProcessMergeComponents.
+ - Fixed: alpha support in image:CopyPlane()
+ and in channel indexing in Lua.
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
@@ -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);
diff --git a/src/lua5/imlua_process.c b/src/lua5/imlua_process.c
index 863c1d6..198d0e5 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.8 2009/10/01 02:56:58 scuri Exp $
+ * $Id: imlua_process.c,v 1.9 2010/01/06 20:16:30 scuri Exp $
*/
#include
@@ -2009,18 +2009,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 +2030,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 +2049,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 +2071,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);
diff --git a/src/process/im_color.cpp b/src/process/im_color.cpp
index b27d4b3..29933c4 100644
--- a/src/process/im_color.cpp
+++ b/src/process/im_color.cpp
@@ -2,7 +2,7 @@
* \brief Color Processing Operations
*
* See Copyright Notice in im_lib.h
- * $Id: im_color.cpp,v 1.1 2008/10/17 06:16:33 scuri Exp $
+ * $Id: im_color.cpp,v 1.2 2010/01/06 20:16:30 scuri Exp $
*/
#include
@@ -142,7 +142,7 @@ void imProcessSplitComponents(const imImage* src_image, imImage** dst_image)
memcpy(dst_image[0]->data[0], src_image->data[0], src_image->plane_size);
memcpy(dst_image[1]->data[0], src_image->data[1], src_image->plane_size);
memcpy(dst_image[2]->data[0], src_image->data[2], src_image->plane_size);
- if (imColorModeDepth(src_image->color_space) == 4)
+ if (imColorModeDepth(src_image->color_space) == 4 || src_image->has_alpha)
memcpy(dst_image[3]->data[0], src_image->data[3], src_image->plane_size);
}
@@ -151,7 +151,7 @@ void imProcessMergeComponents(const imImage** src_image, imImage* dst_image)
memcpy(dst_image->data[0], src_image[0]->data[0], dst_image->plane_size);
memcpy(dst_image->data[1], src_image[1]->data[0], dst_image->plane_size);
memcpy(dst_image->data[2], src_image[2]->data[0], dst_image->plane_size);
- if (imColorModeDepth(dst_image->color_space) == 4)
+ if (imColorModeDepth(dst_image->color_space) == 4 || dst_image->has_alpha)
memcpy(dst_image->data[3], src_image[3]->data[0], dst_image->plane_size);
}
--
cgit v1.2.3