summaryrefslogtreecommitdiff
path: root/src/im_image.cpp
diff options
context:
space:
mode:
authorscuri <scuri>2011-04-04 20:42:46 +0000
committerscuri <scuri>2011-04-04 20:42:46 +0000
commitb2257ad3263f1eaf8dcf637edb480e0c8274fd73 (patch)
treea3838f5b4dccdc7c8bbae13a930e3e9d6738835b /src/im_image.cpp
parent128f620d057c076c445116d264947c993ea5187b (diff)
# New: function imImageMergeAttributes.
Diffstat (limited to 'src/im_image.cpp')
-rw-r--r--src/im_image.cpp24
1 files changed, 23 insertions, 1 deletions
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;