在开发板上进行图片循环播放c语言(800*480) 代码如下:
#include
#include
#include
#include
#include
#include
#include
#include
char* buf[10];
int lcd_fd = -1; //帧缓冲文件描述符
int * plcd = NULL; //帧缓冲设备
//初始化帧缓冲设备
void Lcd_init()
{
int fd = open("/dev/fb0",O_RDWR);
if(fd == -1 ) //打开屏幕出错
{
perror("open pingmv shibai ");
}
lcd_fd = fd;
plcd = mmap(NULL,800*480*4,PROT_READ|PROT_WRITE,
MAP_SHARED,fd,0); //映射到屏幕
if(plcd == MAP_FAILED) //映射出错
{
perror("mmap fail");
return ;
}
}
//画点函数
void Lcd_Draw_Point(int x0, int y0, int color)
{
if (x0 >= 0 && x0 = 0 && y0
int fd = open(bmp_name,O_RDONLY);
if(fd == -1)
{
perror("open bmp error");
}
int width,height; //用来保存宽度及高度
short depth; // 保存色深
unsigned char buf[4];
lseek(fd,0x12,SEEK_SET); //偏移到宽度
read(fd,buf,4);
width = (buf[3]
for(int j = 0; j
a = piexls[k++];
}
else
{
a = 0;
}
color = (a
// int i = 0;
// for(i = 0;i
// i=0;
// }
// }
// }
//关闭屏幕
void Lcd_uninit()
{
munmap(plcd,800*480*4);//解映射
plcd = NULL;
close(lcd_fd);
}
void chushihua()
{
int color = 0x00ffffff;
for(int i = 0;i
Lcd_Draw_Point(j,i,color);
}
}
}
int main()
{
Lcd_init();
chushihua();
// sousuo_bmp(buf);
// xunhuan(buf);
while(1)
{
bmp_play("./1.bmp",0,0);
sleep(2);
bmp_play("./2.bmp",0,0);
sleep(2);
bmp_play("./3.bmp",0,0);
sleep(2);
bmp_play("./4.bmp",0,0);
sleep(2);
}
Lcd_uninit();
}
图片循环可用while循环,或者通过搜索图片路径来达到循环目的,把代码中注释部分取消注释即可,while 部分记得注释。
|