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

来源:互联网 发布:java实现aes256加解密 编辑:程序博客网 时间:2024/06/06 08:36

对于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博客,

原创粉丝点击