/*#include<stdio.h> */ #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <string.h> #include <linux/fb.h> #include <sys/mman.h> #include <sys/ioctl.h> #include <arpa/inet.h> //14byteÎÄŒþÍ· typedef struct { char cfType[2];//ÎÄŒþÀàÐÍ£¬"BM"(0x4D42) long cfSize;//ÎÄŒþŽóС£š×֜ڣ© long cfReserved;//±£Áô£¬ÖµÎª0 long cfoffBits;//ÊýŸÝÇøÏà¶ÔÓÚÎÄŒþÍ·µÄÆ«ÒÆÁ¿£š×֜ڣ© }__attribute__((packed)) BITMAPFILEHEADER; //__attribute__((packed))µÄ×÷ÓÃÊÇžæËß±àÒëÆ÷È¡Ïûœá¹¹ÔÚ±àÒë¹ý³ÌÖеÄÓÅ»¯¶ÔÆë //40byteÐÅϢͷ typedef struct { char ciSize[4];//BITMAPFILEHEADERËùÕŒµÄ×ÖœÚÊý long ciWidth;//¿í¶È long ciHeight;//žß¶È char ciPlanes[2];//Ä¿±êÉ豞µÄλƜÃæÊý£¬ÖµÎª1 int ciBitCount;//ÿžöÏñËصÄλÊý char ciCompress[4];//ѹËõ˵Ã÷ char ciSizeImage[4];//ÓÃ×֜ڱíÊŸµÄÍŒÏñŽóС£¬žÃÊýŸÝ±ØÐëÊÇ4µÄ±¶Êý char ciXPelsPerMeter[4];//Ä¿±êÉ豞µÄˮƜÏñËØÊý/Ã× char ciYPelsPerMeter[4];//Ä¿±êÉ豞µÄŽ¹Ö±ÏñËØÊý/Ã× char ciClrUsed[4]; //λ͌ʹÓõ÷É«°åµÄÑÕÉ«Êý char ciClrImportant[4]; //Öž¶šÖØÒªµÄÑÕÉ«Êý£¬µ±žÃÓòµÄÖµµÈÓÚÑÕÉ«Êýʱ£š»òÕßµÈÓÚ0ʱ£©£¬±íÊŸËùÓÐÑÕÉ«¶ŒÒ»ÑùÖØÒª }__attribute__((packed)) BITMAPINFOHEADER; typedef struct { unsigned short blue; unsigned short green; unsigned short red; unsigned short reserved; }__attribute__((packed)) PIXEL;//ÑÕɫģʜRGB BITMAPFILEHEADER FileHead; BITMAPINFOHEADER InfoHead; static char *fbp = 0; static int xres = 0; static int yres = 0; static int bits_per_pixel = 0; int showbmp2(); int main ( int argc, char *argv[] ) { int fbfd = 0; int index=0; struct fb_var_screeninfo vinfo; struct fb_fix_screeninfo finfo; long int screensize = 0; 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,%d clock\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel,vinfo.pixclock ); 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"); showbmp2(); //ÉŸ³ý¶ÔÏóÓ³Éä munmap(fbp, screensize); // close(fbfd); return 0; } ///* unsigned char buf[3][1680*1050*4]; unsigned char data[640*480*3]; int showbmp2() { int x,y; int index=0; unsigned char *p; FILE *fp[3]; fp[0] = fopen("./000.bmp","rb+"); fp[1] = fopen("./111.bmp","rb+"); fp[2] = fopen("./222.bmp","rb+"); fread(data,54,1,fp[0]); fread(data,640*480*3,1,fp[0]); for(y=0;y<480;y++) { for(x=0;x<800;x++) { if(x<640) { buf[0][((479-y)*800+x)*4 + 0] = data[((y*640) + x)*3 + 0]; buf[0][((479-y)*800+x)*4 + 1] = data[((y*640) + x)*3 + 1]; buf[0][((479-y)*800+x)*4 + 2] = data[((y*640) + x)*3 + 2]; //buf[1][(479-y)*1680+x)*4 + 3] = data[((y*640) + x)*3 + 0]; } } } // fread(data,54,1,fp[1]); fread(data,640*480*3,1,fp[1]); for(y=0;y<480;y++) { for(x=0;x<1680;x++) { if(x<640) { buf[1][((479-y)*800+x)*4 + 0] = data[((y*640) + x)*3 + 0]; buf[1][((479-y)*800+x)*4 + 1] = data[((y*640) + x)*3 + 1]; buf[1][((479-y)*800+x)*4 + 2] = data[((y*640) + x)*3 + 2]; //buf[1][(479-y)*1680+x)*4 + 3] = data[((y*640) + x)*3 + 0]; } } } // fread(data,54,1,fp[2]); fread(data,640*480*3,1,fp[2]); for(y=0;y<480;y++) { for(x=0;x<1680;x++) { if(x<640) { buf[2][((479-y)*800+x)*4 + 0] = data[((y*640) + x)*3 + 0]; buf[2][((479-y)*800+x)*4 + 1] = data[((y*640) + x)*3 + 1]; buf[2][((479-y)*800+x)*4 + 2] = data[((y*640) + x)*3 + 2]; //buf[1][(479-y)*1680+x)*4 + 3] = data[((y*640) + x)*3 + 0]; } } } fclose(fp[0]); fclose(fp[1]); fclose(fp[2]); // while(1) { memcpy(fbp,buf[index%3],800*480*4); sleep(1); if(index++>100) break; } printf("/nover!/n"); return 0; }