zoukankan      html  css  js  c++  java
  • framebuff 显示子系统

     #include <unistd.h>
    #include <stdio.h>
    #include <fcntl.h>
    #include <linux/fb.h>
    #include <sys/mman.h>


    int main () {
     int fp=0;
     struct fb_var_screeninfo vinfo;
     struct fb_fix_screeninfo finfo;
     long screensize=0;
     char *fbp = 0;
     int x = 0, y = 0;
     long location = 0;
     fp = open ("/dev/fb0",O_RDWR);


     if (fp < 0){
      printf("Error : Can not open framebuffer device/n");
      exit(1);
     }


     if (ioctl(fp,FBIOGET_FSCREENINFO,&finfo)){
      printf("Error reading fixed information/n");
      exit(2);
     }
     
     if (ioctl(fp,FBIOGET_VSCREENINFO,&vinfo)){
      printf("Error reading variable information/n");
      exit(3);
     }


      screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
     /*这就是把fp所指的文件中从开始到screensize大小的内容给映射出来,得到一个指向这块空间的指针*/
     fbp =(char *) mmap (0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fp,0);
       if ((int) fbp == -1)
         {
            printf ("Error: failed to map framebuffer device to memory./n");
            exit (4);
         }
    /*这是你想画的点的位置坐标,(0,0)点在屏幕左上角*/
      x = 0;
      y = 0;
      location = x * (vinfo.bits_per_pixel / 8) + y  *  finfo.line_length;


      *(fbp + location) = value;  /*直接填充赋值来显示*/
     
      munmap (fbp, screensize); /*解除映射*/
      close (fp);    /*关闭文件*/
      return 0;


    }

  • 相关阅读:
    多条件复合搜索的实现
    mysql字符集统一
    JS控制彈出窗口
    mysql常用sql
    正则表达式
    航班时间
    1月19日
    1月28日check小爱用
    在么小猫
    大连美发备考
  • 原文地址:https://www.cnblogs.com/zym0805/p/5984829.html
Copyright © 2011-2022 走看看