diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/im.def | 1 | ||||
| -rw-r--r-- | src/im_attrib.cpp | 16 | ||||
| -rw-r--r-- | src/im_image.cpp | 24 | ||||
| -rw-r--r-- | src/lua5/imlua_image.c | 15 | 
4 files changed, 53 insertions, 3 deletions
@@ -109,6 +109,7 @@ EXPORTS    imImageMatchSize    imImageClear    imImageCopyAttributes +  imImageMergeAttributes    imImageDestroy    imImageGetAttributeList    imImageReshape diff --git a/src/im_attrib.cpp b/src/im_attrib.cpp index 10d4599..b2809bb 100644 --- a/src/im_attrib.cpp +++ b/src/im_attrib.cpp @@ -2,7 +2,7 @@   * \brief Attributes Table   *   * See Copyright Notice in im_lib.h - * $Id: im_attrib.cpp,v 1.3 2009/08/22 04:31:04 scuri Exp $ + * $Id: im_attrib.cpp,v 1.4 2011/04/04 20:42:47 scuri Exp $   */  #include <stdlib.h> @@ -305,6 +305,20 @@ void imAttribTableCopyFrom(imAttribTablePrivate* ptable_dst, const imAttribTable    imAttribTableForEach(ptable_src, (void*)ptable_dst, iCopyFunc);  } +static int iMergeFunc(void* user_data, int index, const char* name, int data_type, int count, const void* data) +{                   +  (void)index; +  imAttribTablePrivate* ptable = (imAttribTablePrivate*)user_data; +  if (!imAttribTableGet(ptable, name, NULL, NULL)) +    imAttribTableSet(ptable, name, data_type, count, data); +  return 1; +} + +void imAttribTableMergeFrom(imAttribTablePrivate* ptable_dst, const imAttribTablePrivate* ptable_src) +{ +  imAttribTableForEach(ptable_src, (void*)ptable_dst, iMergeFunc); +} +  static int iCopyArrayFunc(void* user_data, int index, const char* name, int data_type, int count, const void* data)  {                      (void)index; diff --git a/src/im_image.cpp b/src/im_image.cpp index 5f865f8..712de7f 100644 --- a/src/im_image.cpp +++ b/src/im_image.cpp @@ -2,7 +2,7 @@   * \brief Image Manipulation   *   * See Copyright Notice in im_lib.h - * $Id: im_image.cpp,v 1.7 2010/01/17 18:18:12 scuri Exp $ + * $Id: im_image.cpp,v 1.8 2011/04/04 20:42:47 scuri Exp $   */  #include <stdlib.h> @@ -424,6 +424,28 @@ void imImageCopyAttributes(const imImage* src_image, imImage* dst_image)    iAttributeTableCopy(src_image->attrib_table, dst_image->attrib_table);  } +static void iAttributeTableMerge(const void* src_attrib_table, void* dst_attrib_table) +{ +  const imAttribTable* src_table = (const imAttribTable*)src_attrib_table; +  imAttribTable* dst_table = (imAttribTable*)dst_attrib_table; +  dst_table->MergeFrom(*src_table); +} + +void imImageMergeAttributes(const imImage* src_image, imImage* dst_image) +{ +  assert(src_image); +  assert(dst_image); + +  if (src_image->palette && dst_image->palette && +      src_image->color_space == dst_image->color_space) +  { +    memcpy(dst_image->palette, src_image->palette, 256*sizeof(long)); +    dst_image->palette_count = src_image->palette_count; +  } + +  iAttributeTableMerge(src_image->attrib_table, dst_image->attrib_table); +} +  static int iAttribCB(void* user_data, int index, const char* name, int data_type, int count, const void* data)  {    (void)data_type; diff --git a/src/lua5/imlua_image.c b/src/lua5/imlua_image.c index b8bc1a8..057e757 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.13 2010/10/25 18:29:07 scuri Exp $ + * $Id: imlua_image.c,v 1.14 2011/04/04 20:42:48 scuri Exp $   */  #include <string.h> @@ -546,6 +546,18 @@ static int imluaImageCopyAttributes (lua_State *L)  }  /*****************************************************************************\ + image:MergeAttributes(dst_image) +\*****************************************************************************/ +static int imluaImageMergeAttributes (lua_State *L) +{ +  imImage *src_image = imlua_checkimage(L, 1); +  imImage *dst_image = imlua_checkimage(L, 2); + +  imImageMergeAttributes(src_image, dst_image); +  return 0; +} + +/*****************************************************************************\   image:MatchSize(image2)  \*****************************************************************************/  static int imluaImageMatchSize (lua_State *L) @@ -1056,6 +1068,7 @@ static const luaL_reg imimage_metalib[] = {    {"SetPalette", imluaImageSetPalette},    {"GetPalette", imluaImageGetPalette},    {"CopyAttributes", imluaImageCopyAttributes}, +  {"MergeAttributes", imluaImageMergeAttributes},    {"MatchSize", imluaImageMatchSize},    {"MatchColor", imluaImageMatchColor},    {"MatchDataType", imluaImageMatchDataType},  | 
