#define GRAPHIC_EXT_BLOCK_SIZE 4
-static int __convert_gif_to_rgba(mm_image_info_s *decoded, ColorMapObject *color_map, GifRowType *screen_buffer, unsigned long width, unsigned long height)
+static int __convert_gif_to_rgba(void *data, ColorMapObject *color_map, GifRowType *screen_buffer, unsigned long width, unsigned long height)
{
unsigned long i, j;
GifRowType gif_row;
GifColorType *color_map_entry;
GifByteType *buffer;
- mm_util_debug("__convert_gif_to_rgba");
- if ((decoded->data = (void *)calloc(1, width * height * 4)) == NULL) {
+ mm_util_fenter();
+
+ if ((data = (void *)calloc(1, width * height * 4)) == NULL) {
mm_util_error("Failed to allocate memory required, aborted.");
return MM_UTIL_ERROR_OUT_OF_MEMORY;
}
- buffer = (GifByteType *) decoded->data;
+ buffer = (GifByteType *) data;
for (i = 0; i < height; i++) {
gif_row = screen_buffer[i];
for (j = 0; j < width; j++) {
memcpy(data, read_data_ptr->mem + read_data_ptr->size, size);
read_data_ptr->size += size;
}
+
return size;
}
static int __read_gif(mm_image_info_s *decoded, const char *filename, void *memory)
{
+ int ret = MM_UTIL_ERROR_NONE;
+
int ExtCode, i, j, Row, Col, Width, Height;
size_t Size = 0;
GifRecordType record_type;
unsigned int image_num = 0;
ColorMapObject *ColorMap;
gif_mem_s read_data_ptr;
- int ret;
- mm_util_debug("mm_util_decode_from_gif");
+ mm_util_fenter();
+
if (filename) {
if ((GifFile = DGifOpenFileName(filename, NULL)) == NULL) {
mm_util_error("could not open Gif File");
goto error;
}
- ret = __convert_gif_to_rgba(decoded, ColorMap, screen_buffer, GifFile->SWidth, GifFile->SHeight);
+ ret = __convert_gif_to_rgba(decoded->data, ColorMap, screen_buffer, GifFile->SWidth, GifFile->SHeight);
if (ret != MM_UTIL_ERROR_NONE) {
mm_util_error("could not convert gif to rgba");
ret = MM_UTIL_ERROR_INVALID_OPERATION;
return MM_UTIL_ERROR_NONE;
}
-int _gif_image_create_ext_block(mm_image_info_s *gif_image, int function, int byte_count, ExtensionBlock **ext_block)
+int _gif_image_create_ext_block(int function, int byte_count, ExtensionBlock **ext_block)
{
ExtensionBlock *_ext_block = NULL;
- mm_util_retvm_if(gif_image == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
mm_util_retvm_if(byte_count == 0, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
mm_util_retvm_if(ext_block == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
return MM_UTIL_ERROR_NONE;
}
-int _gif_image_write_ext_block(gif_file_s *gif_file, mm_image_info_s *gif_image)
+int _gif_image_write_ext_block(gif_file_s *gif_file, unsigned int delay_time)
{
int ret = MM_UTIL_ERROR_NONE;
ExtensionBlock *_ext_block = NULL;
GraphicsControlBlock graphic_control_block;
mm_util_retvm_if(gif_file == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- mm_util_retvm_if(gif_image == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- ret = _gif_image_create_ext_block(gif_image, GRAPHICS_EXT_FUNC_CODE, GRAPHIC_EXT_BLOCK_SIZE, &_ext_block);
+ ret = _gif_image_create_ext_block(GRAPHICS_EXT_FUNC_CODE, GRAPHIC_EXT_BLOCK_SIZE, &_ext_block);
mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "_gif_image_alloc_ext_block failed");
mm_util_retvm_if(_ext_block->Bytes == NULL, MM_UTIL_ERROR_OUT_OF_MEMORY, "_gif_image_alloc_ext_block failed");
graphic_control_block.DisposalMode = MM_UTIL_GIF_DISPOSAL_UNSPECIFIED;
graphic_control_block.UserInputFlag = FALSE;
graphic_control_block.TransparentColor = NO_TRANSPARENT_COLOR;
- graphic_control_block.DelayTime = gif_image->delay_time;
+ graphic_control_block.DelayTime = delay_time;
EGifGCBToExtension(&graphic_control_block, _ext_block->Bytes);
}
/* Write graphic control block */
- ret = _gif_image_write_ext_block(gif_file, gif_image);
+ ret = _gif_image_write_ext_block(gif_file, gif_image->delay_time);
mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "_gif_image_write_ext_block failed");
/* Write image description & data */