am3358-based LCD output

Source: Internet
Author: User


/* #include <stdio.h>*/#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include &lt ;fcntl.h> #include <string.h> #include <linux/fb.h> #include <sys/mman.h> #include <sys/io ctl.h> #include <arpa/inet.h>//14byte???   Tí typedef struct {char cftype[2];//??? Tààdí£? " BM "(0x4d42) long cfsize;//??? T?ód?£?x?? Ú£©long Cfreserved;//±£á?£?? Μ?a0 long cfoffbits;//êy? Y??? À?? Óú??? Tí μ??? Ò?á?£?x??  Ú£©}__ATTRIBUTE__ ((packed)) Bitmapfileheader; __ATTRIBUTE__ ((packed)) Μ?x÷ó?ê????? ±àò?? ÷è???? Á11?ú±àò?1y3ì? Dμ?ó??     ˉt???? 40byteD??   ¢í typedef struct {char cisize[4];//bitmapfileheader?ù?? Μ?x?? Úêy Long Ciwidth;//?í?èlong ciheight;//??? Èchar ciplanes[2];//?? ±êéè±?μ??????? Êy£?? Μ?A1 int cibitcount;//???????? Μ??? Êy Char cicompress[4];//?1??? Μ?÷char cisizeimage[4];//ó?x?? Ú±íê?μ?í???? Ód?£??? Êy? Y±? D?ê?4μ?±?êy char cixpelspermeter[4];//?? ±êéè±?Μ?? ®?????? Êy/?xchar ciypelspermeter[4];//?? ±êéè±?μ?? 1?±???? Êy/?xchar Ciclrused[4]; //?? Í?ê1ó?μ÷é?°?μ??? É?êy Char ciclrimportant[4]; //?????? Òaμ??? É?êy£?μ±?? Óòμ?? Μμèóú?? É?êyê±£?? Ò?? Μèóú0ê±£©£?±íê?? Ùód?? E??? Ò?? Ù??    Òa}__attribute__ ((packed)) Bitmapinfoheader;      typedef struct {unsigned short blue;      unsigned short green;      unsigned short red;  unsigned short reserved; }__ATTRIBUTE__ ((packed)) pixel;//?? E?? £ê?  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£oreading 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; //????? Á?? Μ?xü?ód?£?x??      Ú£©screensize = vinfo.xres * Vinfo.yres * VINFO.BITS_PER_PIXEL/8;        printf ("screensize=%d byte\n", screensize); //???       Óó3é? 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 (); É?3y???       Óó3é?  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)                + 0] = data[((y*640) + x) + 0];                buf[0][((479-y) *800+x) + 1] = data[((y*640) + x) + 1];                buf[0][((479-y) *800+x) + 2] = data[((y*640) + x) + 2];            buf[1][(479-y) *1680+x) + 3] = data[((y*640) + x) + 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)                + 0] = data[((y*640) + x) + 0];                buf[1][((479-y) *800+x) + 1] = data[((y*640) + x) + 1];                buf[1][((479-y) *800+x) + 2] = data[((y*640) + x) + 2];            buf[1][(479-y) *1680+x) + 3] = data[((y*640) + x) + 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) + 0];                buf[2][((479-y) *800+x) + 1] = data[((y*640) + x) + 1];                buf[2][((479-y) *800+x) + 2] = data[((y*640) + x) + 2];            buf[1][(479-y) *1680+x) + 3] = data[((y*640) + x) + 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;}


am3358-based LCD output

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.