另一种MTK特效制作的方法,层复制

对于MTK平台来说,菜单和屏幕特效曾经在很长的一段时间里,影响甚远。
但对于其设计过程和方法,由于各种各样的原因,很少有人提及。
这里介绍一种不同于前几天日志所载之方法的另一种方法,就是合并图层,其核心实现函数如下。
void my_gdi_layer_copy(gdi_layer_struct* dst_layer, int dst_x, int dst_y, int width, int height,
 gdi_layer_struct* src_layer, int src_x, int src_y)
{
 U16 *dst_buf, *src_buf;
 int i;
 if (dst_x < 0 || dst_y < 0 || dst_x + width > dst_layer->width || dst_y + height > dst_layer->height)
 {
  if (dst_x < 0)
  {
   width -= -dst_x;
   src_x += -dst_x;
   dst_x = 0;
  }
  if (dst_y < 0)
  {
   height -= -dst_y;
   src_y += -dst_y;
   dst_y = 0;
  }
  if (dst_x + width > dst_layer->width)
  {
   width = dst_layer->width - dst_x;
  }
  if (dst_y + height > dst_layer->height)
  {
   height = dst_layer->height - dst_y;
  }
 }
 if (src_x < 0 || src_y < 0 || src_x + width > src_layer->width || src_y + height > src_layer->height)
 {
  if (src_x < 0)
  {
   width -= -src_x;
   dst_x += -src_x;
   src_x = 0;
  }
  if (src_y < 0)
  {
   height -= -src_y;
   dst_y += -src_y;
   src_y = 0;
  }
  if (src_x + width > src_layer->width)
  {
   width = src_layer->width - src_x;
  }
  if (src_y + height > src_layer->height)
  {
   height = src_layer->height - src_y;
  }
 }
 if (width <= 0 || height <= 0)
  return;
 dst_buf = (U16 *)dst_layer->buf_ptr + dst_y * dst_layer->width + dst_x;
 src_buf = (U16 *)src_layer->buf_ptr + src_y * src_layer->width + src_x;
 for (i = 0; i < height; i ++)
 {
  memcpy(dst_buf, src_buf, width * 2);
  dst_buf += dst_layer->width;
  src_buf += src_layer->width;
 }
}
有兴趣的朋友可以自己利用该函数研发各种各样的变化效果。
这个函数,加上我前一段时间提供的另一种方法,大致可以制作二十种左右的效果。

本文来自CSDN博客,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值