#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <linux/fb.h>
#include <fcntl.h>
#include <errno.h>
#define SUCCESS 1
#define FAILURE 0
int cls_screen (int x, int y, int w, int h)
{
int fd = 0;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
long int screen_size = 0;
unsigned char *fb_mem, *temp;
int i = 0;
fd = open ("/dev/fb0",O_RDWR);
if (ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) == -1)
{
printf("Failed FBIOGET_VSCREENINFO on /dev/fb0 (%s)\n",strerror(errno));
close(fd);
return FAILURE;
}
if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo) == -1)
{
printf("Failed FBIOGET_FSCREENINFO on /dev/fb0 (%s)\n",strerror(errno));
close(fd);
return FAILURE;
}
screen_size = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
fb_mem = mmap(NULL,screen_size,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0);
temp = fb_mem;
if(w >= vinfo.xres - x)
w = vinfo.xres;
if(h >= vinfo.yres - y)
h = vinfo.yres;
for (i=0;i < h;i++)
{
memset (temp, 0, w * vinfo.bits_per_pixel / 8);
temp = temp + vinfo.xres * vinfo.bits_per_pixel / 8;
}
strcpy(temp,origin_mem);
munmap(NULL,screen_size);
return SUCCESS;
}
c语言实现对lcd屏清屏操作
2星 需积分: 35 12 浏览量
2012-12-20
20:30:13
上传
评论
收藏 670B RAR 举报
lishi_1991
- 粉丝: 50
- 资源: 12