From 24bddff3f5df8f39726f0050de62e56f8e68cfe3 Mon Sep 17 00:00:00 2001 From: hj kim Date: Tue, 19 Mar 2019 16:05:25 +0900 Subject: [PATCH] Add new mm_image_clone_image() API Change-Id: I1e34098d9c475f8faec0e07835fc202bc571ff36 --- common/include/mm_util_image.h | 2 +- common/mm_util_image.c | 30 ++++++++++++++++++++++++++++++ magick/mm_util_magick.c | 0 3 files changed, 31 insertions(+), 1 deletion(-) mode change 100644 => 100755 magick/mm_util_magick.c diff --git a/common/include/mm_util_image.h b/common/include/mm_util_image.h index 01701cf..fbeb21f 100755 --- a/common/include/mm_util_image.h +++ b/common/include/mm_util_image.h @@ -33,7 +33,7 @@ void mm_image_debug_image(mm_util_image_h image, const char *message); int mm_image_create_image(unsigned int width, unsigned int height, mm_util_color_format_e color, const unsigned char *data, size_t size, mm_util_image_h *image); - +int mm_image_clone_image(mm_util_image_h src, mm_util_image_h *dst); int mm_image_set_delay_time(mm_util_image_h image, unsigned int delay_time); int mm_image_get_delay_time(mm_util_image_h image, unsigned int *delay_time); /* After @data is used, it must be released using free().*/ diff --git a/common/mm_util_image.c b/common/mm_util_image.c index 8e52f04..ab538d8 100755 --- a/common/mm_util_image.c +++ b/common/mm_util_image.c @@ -86,6 +86,36 @@ int mm_image_create_image(unsigned int width, unsigned int height, return MM_UTIL_ERROR_NONE; } +int mm_image_clone_image(mm_util_image_h src, mm_util_image_h *dst) +{ + mm_image_info_s *_src = (mm_image_info_s *)src; + mm_image_info_s *_dst = NULL; + + mm_util_retvm_if(!src, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid src"); + mm_util_retvm_if(!dst, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid dst"); + + _dst = (mm_image_info_s *)calloc(1, sizeof(mm_image_info_s)); + mm_util_retvm_if((_dst == NULL), MM_UTIL_ERROR_OUT_OF_MEMORY, "Memory allocation failed"); + + _dst->width = _src->width; + _dst->height = _src->height; + _dst->color = _src->color; + _dst->size = _src->size; + + _dst->data = calloc(1, _dst->size); + if (!_dst->data) { + mm_util_error("Memory allocation failed"); + mm_image_destroy_image(_dst); + return MM_UTIL_ERROR_OUT_OF_MEMORY; + } + + memcpy(_dst->data, _src->data, _dst->size); + + *dst = (mm_util_image_h)_dst; + + return MM_UTIL_ERROR_NONE; +} + int mm_image_set_delay_time(mm_util_image_h image, unsigned int delay_time) { mm_image_info_s *_image = (mm_image_info_s *)image; diff --git a/magick/mm_util_magick.c b/magick/mm_util_magick.c old mode 100644 new mode 100755 -- 2.7.4