From b2257ad3263f1eaf8dcf637edb480e0c8274fd73 Mon Sep 17 00:00:00 2001 From: scuri Date: Mon, 4 Apr 2011 20:42:46 +0000 Subject: # New: function imImageMergeAttributes. --- src/im_image.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/im_image.cpp') 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 @@ -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; -- cgit v1.2.3