unsigned long height; /**< Height */
unsigned long x; /**< X position */
unsigned long y; /**< Y position */
- gboolean is_transparent; /**< Is frame transparency set */
- mm_util_gif_color_s transparent_color; /**< Transparency color */
- mm_util_gif_disposal disposal_mode; /**< Disposal mode */
void *data; /**< Data */
} mm_util_gif_frame_data;
int mm_util_gif_image_set_position(mm_gif_image_h gif_image_h, const int left, const int top, const int width, const int height);
/**
- * This function sets the disposal mode(graphic control) of the single image(frame).
- *
- * @param gif_image_h [in] the handle of the single image.
- * @param disposal_mode [in] the disposal mode of the single image.
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @since R1, 2.0
- * @see mm_util_gif_image_create
- * @pre mm_util_gif_image_create
- */
-int mm_util_gif_image_set_disposal_mode(mm_gif_image_h gif_image_h, const mm_util_gif_disposal disposal_mode);
-
-/**
* This function sets the delay time of the single image(frame).
*
* @param gif_image_h [in] the handle of the single image.
int mm_util_gif_encode_set_resolution(mm_gif_file_h gif_file_h, const int width, const int height);
/**
- * This function sets the times to play animated gif repeatly.
- * If set the repeat mode to false, play animated gif once.
- * else set the repeat to true, play animated gif infinately.
- * If set the repeat_count as 1, animated gif was played one more times. It mean that animated gif will be played two times.
- *
- * @param gif_file_h [in] the handle of the gif data.
- * @param repeat [in] the repeat mode to play animated gif.
- * @param repeat_count [in] the times to play animated gif repeatly.
- * @return This function returns zero on success, or negative value with error code.
- * @remark
- * @since R1, 2.0
- * @see mm_util_gif_encode_create
- * @pre mm_util_gif_encode_create
- */
-int mm_util_gif_encode_set_repeat(mm_gif_file_h gif_file_h, gboolean repeat_mode, const unsigned short repeat_count);
-
-/**
* This function starts encoding image.
*
* @param gif_file_h [in] the handle of the gif data.
return ret;
}
-int __gif_get_index_in_colormap(gif_image_s *gif_image)
-{
- int i = 0;
- mm_util_retvm_if(gif_image->image_desc.ColorMap == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- mm_util_retvm_if(gif_image->image_desc.ColorMap->Colors == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- /* default is no transparent color */
- gif_image->graphic_control_block.TransparentColor = -1;
-
- for (i = 0; i < gif_image->image_desc.ColorMap->ColorCount; i++) {
- if (gif_image->image_desc.ColorMap->Colors[i].Red == gif_image->transparent_color.Red &&
- gif_image->image_desc.ColorMap->Colors[i].Green == gif_image->transparent_color.Green &&
- gif_image->image_desc.ColorMap->Colors[i].Blue == gif_image->transparent_color.Blue) {
- gif_image->graphic_control_block.TransparentColor = i;
- break;
- }
- }
-
- return MM_UTIL_ERROR_NONE;
-}
-
int _gif_encode_open_file(gif_file_s *gif_file)
{
mm_util_fenter();
int _gif_encode_init(gif_file_s *gif_file)
{
- int ret = MM_UTIL_ERROR_NONE;
- ExtensionBlock *_ext_block = NULL;
-
mm_util_fenter();
mm_util_retvm_if(gif_file == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- if (gif_file->is_repeat) {
- /* set netscape 2.0 application data to play animated gif */
- ret = _gif_image_alloc_glob_ext_block(gif_file->GifFile, APPLICATION_EXT_FUNC_CODE, APP_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");
-
- memcpy(_ext_block->Bytes, APP_EXT_BLOCK_DATA, APP_EXT_BLOCK_SIZE);
-
- /* write sub block of application data to play animated gif with repeat count */
- ret = _gif_image_alloc_glob_ext_block(gif_file->GifFile, CONTINUE_EXT_FUNC_CODE, SUB_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");
- _ext_block->Bytes[0] = NETSCAPE_SUB_BLOCK_INDEX;
- if (gif_file->repeat_count == 0) {
- _ext_block->Bytes[1] = 0x00;
- _ext_block->Bytes[2] = 0x00;
- } else {
- _ext_block->Bytes[1] = (gif_file->repeat_count & 0xff);
- _ext_block->Bytes[2] = ((gif_file->repeat_count >> 8) & 0xff);
- }
- } else {
- /* change gif version to 89a due to extension blocks. */
- EGifSetGifVersion(gif_file->GifFile, TRUE);
- }
+ /* change gif version to 89a due to extension blocks. */
+ EGifSetGifVersion(gif_file->GifFile, TRUE);
return MM_UTIL_ERROR_NONE;
}
pImage->image_desc.Interlace = FALSE; /* don't change this, fixed value */
pImage->ext_block_count = 0;
pImage->ext_blocks = NULL;
- pImage->has_color_map = FALSE;
- pImage->has_transparent = FALSE;
pImage->graphic_control_block.DisposalMode = MM_UTIL_GIF_DISPOSAL_UNSPECIFIED;
pImage->graphic_control_block.UserInputFlag = FALSE;
pImage->graphic_control_block.TransparentColor = NO_TRANSPARENT_COLOR;
return MM_UTIL_ERROR_NONE;
}
-int mm_util_gif_image_set_disposal_mode(mm_gif_image_h gif_image_h, const mm_util_gif_disposal disposal_mode)
-{
- gif_image_s *gif_image = (gif_image_s *)gif_image_h;
-
- mm_util_retvm_if(gif_image == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- mm_util_info("mode = %d", disposal_mode);
-
- gif_image->graphic_control_block.DisposalMode = (int)disposal_mode;
-
- return MM_UTIL_ERROR_NONE;
-}
-
int mm_util_gif_image_set_delay_time(mm_gif_image_h gif_image_h, const int delay_time)
{
gif_image_s *gif_image = (gif_image_s *)gif_image_h;
return MM_UTIL_ERROR_NONE;
}
-int mm_util_gif_image_set_tp_color(mm_gif_image_h gif_image_h, const mm_util_gif_color_s tp_color)
-{
- gif_image_s *gif_image = (gif_image_s *)gif_image_h;
-
- mm_util_retvm_if(gif_image == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- gif_image->has_transparent = TRUE;
- gif_image->transparent_color.Red = tp_color.red;
- gif_image->transparent_color.Green = tp_color.green;
- gif_image->transparent_color.Blue = tp_color.blue;
-
- return MM_UTIL_ERROR_NONE;
-}
-
-int mm_util_gif_image_set_color_map(mm_gif_image_h gif_image_h, const int number_of_colors, mm_util_gif_color_s *colors)
-{
- gif_image_s *gif_image = (gif_image_s *)gif_image_h;
-
- mm_util_retvm_if(gif_image == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- mm_util_retvm_if(number_of_colors == 0, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- mm_util_retvm_if(colors == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
-
- mm_util_info("ptr = %p, number_of_colors = %d", colors, number_of_colors);
-
- GifColorType *color_map = (GifColorType*)colors;
-
- gif_image->image_desc.ColorMap = GifMakeMapObject(number_of_colors, color_map);
- mm_util_retvm_if(gif_image->image_desc.ColorMap == NULL, MM_UTIL_ERROR_INVALID_OPERATION, "To make color map is failed");
- gif_image->has_color_map = TRUE;
-
- return MM_UTIL_ERROR_NONE;
-}
-
int mm_util_gif_image_set_image(mm_gif_image_h gif_image_h, const unsigned char *image_data)
{
gif_image_s *gif_image = (gif_image_s *)gif_image_h;
mm_util_retvm_if(gif_file == NULL, MM_UTIL_ERROR_OUT_OF_MEMORY, "Memory allocation failed");
/* initialize data before set */
- gif_file->color_res = 8;
- gif_file->background_color = 0;
gif_file->color_map = NULL;
gif_file->is_started = FALSE;
- gif_file->is_repeat = FALSE;
- gif_file->repeat_count = 0;
*gif_file_h = (mm_gif_file_h)gif_file;
return MM_UTIL_ERROR_NONE;
}
-int mm_util_gif_encode_set_repeat(mm_gif_file_h gif_file_h, gboolean repeat_mode, const unsigned short repeat_count)
-{
- gif_file_s *gif_file = (gif_file_s *)gif_file_h;
-
- mm_util_retvm_if(gif_file == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
- mm_util_retvm_if(gif_file->is_started, MM_UTIL_ERROR_INVALID_OPERATION, "Encoding has already started");
-
- mm_util_info("repeat = %d, count = %d", repeat_mode, repeat_count);
-
- gif_file->is_repeat = repeat_mode;
- gif_file->repeat_count = repeat_count;
-
- return MM_UTIL_ERROR_NONE;
-}
-
int mm_util_gif_encode_start(mm_gif_file_h gif_file_h)
{
int ret = MM_UTIL_ERROR_NONE;
/* Write screen description */
if (EGifPutScreenDesc(gif_file->GifFile, gif_file->width, gif_file->height,
- gif_file->color_res, gif_file->background_color, gif_file->color_map) == GIF_ERROR) {
+ 8 /* color_res */, 0 /* background_color */, gif_file->color_map) == GIF_ERROR) {
mm_util_error("could not put screen description");
_gif_encode_close_file(gif_file);
return MM_UTIL_ERROR_INVALID_OPERATION;
}
/* Make local color map */
- if (gif_image->has_color_map == FALSE) {
- ret = __gif_make_color_map(gif_image);
- mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "__gif_make_color_map failed");
- }
-
- if (gif_image->has_transparent) {
- ret = __gif_get_index_in_colormap(gif_image);
- mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "__gif_get_index_in_colormap failed");
- }
+ ret = __gif_make_color_map(gif_image);
+ mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "__gif_make_color_map failed");
/* Write extension blocks */
ret = _gif_image_write_ext_blocks(gif_file, gif_image);