📄 img_msg_handler.c
字号:
S32 resz_h = (S32) img_context_gif_info->resz_h;
S32 lx, ly, lw, lh;
lx = img_context_gif_info->x >> resz_w;
ly = img_context_gif_info->y >> resz_h;
lw = img_context_gif_info->w >> resz_w;
lh = img_context_gif_info->h >> resz_h;
if (img_context_gif_info->use_work_buf && lw > 0 && lh > 0)
{
gdi_color_format cf;
gdi_color src_key, layer_key;
gd_bitblt_func bitblt;
S32 dx1, dy1, dx2, dy2;
S32 sx1, sy1, sx2, sy2;
if (img_context_gif_info->transparent_flag)
{
src_key = img_context_gif_info->src_key_2d;
}
else
{
src_key = 0x01ffffff;
}
layer_key = img_context_gif_config.src_key;
gdi_image_gif_cf_from_hw(img_context_gif_config.out_format, &cf);
if ((img_context_gif_info->lwidth >> resz_w) == img_context_gif_config.expect_w
&& (img_context_gif_info->lheight >> resz_h) == img_context_gif_config.expect_h)
{
dx1 = img_context_gif_config.dest_x + lx;
dy1 = img_context_gif_config.dest_y + ly;
dx2 = dx1 + lw - 1;
dy2 = dy1 + lh - 1;
sx1 = img_context_gif_info->wb_dest_x + lx;
sy1 = img_context_gif_info->wb_dest_y + ly;
sx2 = sx1 + lw - 1;
sy2 = sy1 + lh - 1;
bitblt = gd_bitblt[cf];
}
else
{
S32 rw1, rw2;
S32 rh1, rh2;
/* init rh/rw */
rw1 = img_context_gif_config.expect_w - 1;
rh1 = img_context_gif_config.expect_h - 1;
rw2 = (img_context_gif_info->lwidth >> resz_w) - 1;
rh2 = (img_context_gif_info->lheight >> resz_h) - 1;
if (rw2 <= 0)
{
rw2 = 1;
}
if (rh2 <= 0)
{
rh2 = 1;
}
/* calculate (sx1,sy1)-(sx2,sy2) */
sx1 = lx;
sy1 = ly;
sx2 = sx1 + lw - 1;
sy2 = sy1 + lh - 1;
/* calculate (dx1,dy1)-(dx2,dy2) */
dx1 = sx1 * rw1 / rw2;
dx2 = sx2 * rw1 / rw2;
dy1 = sy1 * rh1 / rh2;
dy2 = sy2 * rh1 / rh2;
/* move to real destination */
sx1 += img_context_gif_info->wb_dest_x;
sx2 += img_context_gif_info->wb_dest_x;
sy1 += img_context_gif_info->wb_dest_y;
sy2 += img_context_gif_info->wb_dest_y;
dx1 += img_context_gif_config.dest_x;
dx2 += img_context_gif_config.dest_x;
dy1 += img_context_gif_config.dest_y;
dy2 += img_context_gif_config.dest_y;
bitblt = gd_resize_bitblt[cf];
}
bitblt(
img_context_gif_config.output_buffer_adrs,
img_context_gif_config.shadow_w,
img_context_gif_config.shadow_h,
dx1,
dy1,
dx2,
dy2,
img_context_gif_config.work_buffer_adrs,
img_context_gif_info->wb_width,
img_context_gif_info->wb_height,
sx1,
sy1,
sx2,
sy2,
img_context_gif_config.clip_x1,
img_context_gif_config.clip_y1,
img_context_gif_config.clip_x2,
img_context_gif_config.clip_y2,
src_key,
layer_key);
}
IMG_ENTER_STATE(IMG_IDLE);
}
}
#endif /* defined(USE_HW_GIF_DECODER_V2) */
#if defined(USE_HW_PNG_DECODER_V1) || defined(USE_SW_PNG_DECODER)
else if (IMG_IN_STATE(IMG_PNG_DECODE))
{
png_report_status_enum status = ind_p->cause;
while (1)
{
switch (status)
{
case PNG_BLOCK_END:
status = png_decode_resume();
continue;
case PNG_FINISH_IMAGE:
result = MED_RES_OK;
is_finish = KAL_TRUE;
break;
// case PNG_USE_G2D:
// img_context_png_config.output_buffer_adrs = (kal_uint32)med_alloc_ext_mem(img_context_png_config.output_buffer_size);
// status = png_decode_resume();
// continue;
case PNG_DECODING:
break;
case PNG_DECODE_TIMEOUT:
result = MED_RES_IMG_DECODE_TIME_OUT;
is_finish = KAL_TRUE;
break;
default:
result = MED_RES_FAIL;
is_finish = KAL_TRUE;
}
break;
}
if (is_finish) /* png finializer */
{
IMG_ENTER_STATE(IMG_IDLE);
if (img_context_png_config.decode_mode == PNG_DECODE_FILE)
{
med_free_ext_mem((void **)&img_context_png_config.in_buffer_adrs);
}
if (img_context_png_info->use_work_buf && result == MED_RES_OK) /* result is in work buffer */
{
S32 sw, sh;
S32 resz_w = (S32) img_context_png_info->resz_w;
S32 resz_h = (S32) img_context_png_info->resz_h;
sw = img_context_png_info->img_w >> resz_w;
sh = img_context_png_info->img_h >> resz_h;
if (sw > 0 && sh > 0)
{
gdi_color_format cf;
gdi_color src_key, layer_key;
gd_bitblt_func bitblt;
S32 dx1, dy1, dx2, dy2;
S32 sx1, sy1, sx2, sy2;
if (img_context_png_info->num_trans > 0)
{
src_key = img_context_png_info->src_key;
}
else
{
src_key = 0x01ffffff;
}
layer_key = img_context_png_config.src_key;
gdi_image_png_cf_from_hw(img_context_png_config.out_format, &cf);
dx1 = img_context_png_config.dest_x;
dy1 = img_context_png_config.dest_y;
dx2 = dx1 + img_context_png_config.expect_w - 1;
dy2 = dy1 + img_context_png_config.expect_h - 1;
sx1 = img_context_png_info->wb_dest_x;
sy1 = img_context_png_info->wb_dest_y;
sx2 = img_context_png_info->wb_dest_x + (img_context_png_info->img_w >> resz_w) - 1;
sy2 = img_context_png_info->wb_dest_y + (img_context_png_info->img_h >> resz_h) - 1;
{
char buf[128];
sprintf(
buf,
"(%d,%d) (%d,%d,%d,%d) (%d,%d,%d,%d) %d",
img_context_png_info->img_w,
img_context_png_info->img_h,
sx1,
sy1,
sx2,
sy2,
dx1,
dy1,
dx2,
dy2,
resz_w);
kal_print(buf);
}
if (img_context_png_config.expect_w == img_context_png_info->img_w >> resz_w
&& img_context_png_config.expect_h == img_context_png_info->img_h >> resz_h)
{
bitblt = gd_bitblt[cf];
}
else
{
bitblt = gd_resize_bitblt[cf];
}
bitblt(
(U8*) img_context_png_config.output_buffer_adrs,
img_context_png_config.shadow_w,
img_context_png_config.shadow_h,
dx1,
dy1,
dx2,
dy2,
(U8*) img_context_png_config.work_buffer_adrs,
img_context_png_info->wb_width,
img_context_png_info->wb_height,
sx1,
sy1,
sx2,
sy2,
img_context_png_config.clip_x1,
img_context_png_config.clip_y1,
img_context_png_config.clip_x2,
img_context_png_config.clip_y2,
src_key,
layer_key);
}
}
// med_free_ext_mem((void**)&img_context_png_config.work_buffer_adrs);
med_free_ext_mem((void **)&img_context_png_config.upper_buffer);
png_decode_stop();
}
}
#endif /* defined(USE_HW_PNG_DECODER_V1) */
/* global finializer */
if (is_finish)
{
if (img_context_p->callback != NULL)
{
img_context_p->callback(result);
}
if (img_context_p->blocking)
{
img_set_result_ext(result, ind_p->arg0, ind_p->arg1);
IMG_SET_EVENT(IMG_EVT_DECODE);
}
else
{
img_send_decode_finish_ind(result, img_context_p->seq_num);
}
}
}
/*****************************************************************************
* FUNCTION
* img_cal_work_buffer_info
* DESCRIPTION
*
* PARAMETERS
* ret_ratio [?]
* wb_dest_x [?]
* wb_dest_y [?]
* wb_width [?]
* wb_height [?]
* wb_pixel_size [IN]
* img_w [IN]
* img_h [IN]
* dest_x [IN]
* dest_y [IN]
* expect_w [IN]
* expect_h [IN]
* clipx1 [IN]
* clipy1 [IN]
* clipx2 [IN]
* clipy2 [IN]
* RETURNS
* void
*****************************************************************************/
void img_cal_work_buffer_info(
kal_uint8 *ret_ratio,
kal_int16 *wb_dest_x,
kal_int16 *wb_dest_y,
kal_uint16 *wb_width,
kal_uint16 *wb_height,
kal_uint32 wb_pixel_size,
kal_uint16 img_w,
kal_uint16 img_h,
kal_int16 dest_x,
kal_int16 dest_y,
kal_uint16 expect_w,
kal_uint16 expect_h,
kal_int16 clipx1,
kal_int16 clipy1,
kal_int16 clipx2,
kal_int16 clipy2)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 dx, dy;
S32 dx1, dy1, dx2, dy2, dw, dh;
S32 sx1, sy1, sx2, sy2, sw, sh;
S32 rw1, rw2, rh1, rh2;
S32 ratio;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* initialize default value */
*ret_ratio = 0;
*wb_dest_x = dest_x;
*wb_dest_y = dest_y;
dx = dest_x;
dy = dest_y;
dw = expect_w;
dh = expect_h;
sw = img_w;
sh = img_h;
rw1 = sw - 1;
rw2 = dw - 1;
rh1 = sh - 1;
rh2 = dh - 1;
if (rw2 <= 0)
{
rw2 = 1;
}
if (rh2 <= 0)
{
rh2 = 1;
}
/* calculate C (the real output area) */
dx1 = dx;
dy1 = dy;
dx2 = dx1 + dw - 1;
dy2 = dy1 + dh - 1;
GDI_CLIP_TWO_RECT1(dx1, dy1, dx2, dy2, clipx1, clipy1, clipx2, clipy2, return);
dw = dx2 - dx1 + 1;
dh = dy2 - dy1 + 1;
/* calculate S ( the source area which is mapping to C ) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -