linux下的framebuffer显示图片
2013-08-12 16:14:00 来源:WEB开发网 void showbmp2()
{
int x,y;
unsigned char *p;
int index=0;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
struct fb_bitfield red;
struct fb_bitfield green;
struct fb_bitfield blue;
//open the showdeviece
fbfd = open("/dev/fb0", O_RDWR);
if (!fbfd)
{
printf("Error: cannot open framebuffer device.\n");
exit(1);
}
if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo))
{
printf("Error£ºreading fixed information.\n");
exit(2);
}
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo))
{
printf("Error: reading variable information.\n");
exit(3);
}
printf("R:%d,G:%d,B:%d \n", vinfo.red, vinfo.green, vinfo.blue );
printf("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel );
xres = vinfo.xres;
yres = vinfo.yres;
bits_per_pixel = vinfo.bits_per_pixel;
//ŒÆËãÆÁÄ»µÄ×ÜŽóС£š×֜ڣ©
screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
printf("screensize=%d byte\n",screensize);
//¶ÔÏóÓ³Éä
fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0);
if ((int)fbp == -1)
{
printf("Error: failed to map framebuffer device to memory.\n");
exit(4);
}
printf("sizeof file header=%d\n", sizeof(BITMAPFILEHEADER));
printf("into show_bmp function\n");
FILE *fp[3];
fp[0] = fopen("./333.bmp","rb+");
fp[1] = fopen("./444.bmp","rb+");
fp[2] = fopen("./555.bmp","rb+");
fread(data,54,1,fp[0]);
fread(data,WIDTH*HEIGHT*3,1,fp[0]);
for(y=0;y<HEIGHT;y++)
{
for(x=0;x<WIDTH;x++)
{
//if(x<640)
{
buf[1][(((HEIGHT-1)-y)*WIDTH+x)*4 + 0] = data[((y*WIDTH) + x)*3 + 0];
buf[1][(((HEIGHT-1)-y)*WIDTH+x)*4 + 1] = data[((y*WIDTH) + x)*3 + 1];
buf[1][(((HEIGHT-1)-y)*WIDTH+x)*4 + 2] = data[((y*WIDTH) + x)*3 + 2];
//buf[1][(479-y)*WIDTH+x)*4 + 3] = data[((y*640) + x)*3 + 0];
}
}
}
//
fread(data,54,1,fp[1]);
fread(data,WIDTH*HEIGHT*3,1,fp[1]);
for(y=0;y<HEIGHT;y++)
{
for(x=0;x<WIDTH;x++)
{
//if(x<640)
{
buf[2][(((HEIGHT-1)-y)*WIDTH+x)*4 + 0] = data[((y*WIDTH) + x)*3 + 0];
buf[2][(((HEIGHT-1)-y)*WIDTH+x)*4 + 1] = data[((y*WIDTH) + x)*3 + 1];
buf[2][(((HEIGHT-1)-y)*WIDTH+x)*4 + 2] = data[((y*WIDTH) + x)*3 + 2];
//buf[1][(479-y)*WIDTH+x)*4 + 3] = data[((y*640) + x)*3 + 0];
}
}
}
//
fread(data,54,1,fp[2]);
fread(data,WIDTH*HEIGHT*3,1,fp[2]);
for(y=0;y<HEIGHT;y++)
Tags:linux framebuffer 显示
编辑录入:爽爽 [复制链接] [打 印]- ››linux下两台服务器文件实时同步方案设计和实现
- ››Linux文件描述符中的close on exec标志位
- ››Linux下管道使用的一些限制
- ››Linux 误删/usr/bin 解决方法
- ››linux 添加新用户并赋予sudo执行权限
- ››linux常用软件安装方法
- ››Linux的分区已经被你从Windows中删除,系统启动后...
- ››linux enable命令大全
- ››Linux实现基于Loopback的NVI(NAT Virtual Interfa...
- ››Linux远程访问windows时,出现"连接被对端重...
- ››linux中使用head命令和tail命令查看文件中的指定行...
- ››linux swap 分区调控(swap分区 lvm管理)
更多精彩
赞助商链接