Skip to content
Ever-Never edited this page Jul 9, 2018 · 1 revision
  • 说明

帧动画的添加,和播放

1、添加图片控件

LIBAROMA_CONTROLP libaroma_ctl_image(LIBAROMA_WINDOWP win, word id, char *src, int x, int y, int w, int h)
参数说明
参数 说明
win 对应的win
id ctl ID
src 图片的来源,file
x 坐标x
y 坐标y
w
h

2、添加帧动画

byte libaroma_ctl_image_set_animation(LIBAROMA_CONTROLP ctl, char* addr,bytep index, byte count,byte rate,byte repeat,void * start_cb,void * repeat_cb,void * end_cb)
参数说明
参数 说明
ctl 需要添加帧动画的ctl
addr 帧动画的图片地址
index to set animation order , if set NULL play animation in default order
count 播放的图片张数
rate 速度,一张图片播放时间
repeat 重复次数,0表示不重复只播放一次,AMIMATION_FOREVER一直播放
start_cb 当需要在播放第一帧 动画时hook,添加start_cb
repeat_cb 当有重复播放时,如果有需要在重复播放时hook,则添加repeat_cb
end_cb 当需要在播放结束hook时,添加end_cb
return 0表示填加失败,1表示添加成功

3、设置播放和停止播放

byte libaroma_ctl_image_animation_set_play_or_stop(LIBAROMA_CONTROLP ctl,byte is_paly)
参数说明
参数 说明
ctl 需要播放的控件
is_play 0,停止播放,1开始播放

4、设置重播次数

byte  libaroma_ctl_image_animation_set_repeat(LIBAROMA_CONTROLP ctl ,byte repeat)
参数说明
参数 说明
ctl 需要播放的控件
repeat 重播次数

5、例子

假设想有图片生成了图片数组png_res,里面的图片index为0-40现在想播放其中10个图片,一张图片播放2s,重复播放3次,并设置了test_start_cb test_end_cb test_repeat_cb_

void test_start_cb(LIBAROMA_CONTROLP ctl,LIBAROMA_CANVASP c)
{
    libaroma_draw_rect( c,1,0x5d,4,8,RGB(00ff00), 0xff);
    libaroma_draw_rect( c,1,0x53,4,8,RGB(00ff00), 0xff);
}
void  test_end_cb(LIBAROMA_CONTROLP ctl,LIBAROMA_CANVASP c)
{
//    libaroma_ctl_indicator_set_position(indicator,4,RGB(0000ff));

    libaroma_draw_rect( c,20,0x5d,4,8,RGB(ffffff), 0xff);
    libaroma_draw_rect( c,20,0x53,4,8,RGB(ffffff), 0xff);

}
byte testy=0x65;
void  test_repeat_cb(LIBAROMA_CONTROLP ctl,LIBAROMA_CANVASP c)
{

    libaroma_draw_rect( c,25,testy,4,8,RGB(ffff00), 0xff);
    libaroma_draw_rect( c,25,testy+10,4,8,RGB(ffff00), 0xff);
    testy+=20;

}
LIBAROMA_WINDOWP win = libaroma_window(NULL, 0, 0, LIBAROMA_SIZE_FULL,LIBAROMA_SIZE_FULL); 
LIBAROMA_CONTROLP image2 = libaroma_ctl_image(win, 3, NULL,  libaroma_dp(0), libaroma_px(0), libaroma_dp(30), libaroma_px(30));
byte index[10]={4,3,2,1,0,5,4,6,8,0};
libaroma_ctl_image_set_animation(image2,(char *)png_res,NULL, 5, 2,3,test_start_cb,test_repeat_cb,test_end_cb);
libaroma_ctl_image_animation_set_play_or_stop(image2,1);
libaroma_ctl_image_animation_set_repeat( image2 ,3);

Clone this wiki locally