title: how to get buffer get buffer screen device android
body: <p>I have a function get buffer screen device android</p>
  
  <pre><code>struct fb_var_screeninfo scrinfo;
  struct fb_fix_screeninfo fscrinfo;
  
  int initFB(void)
  {  
    L("--Initializing framebuffer access method--\n");
  
    fbmmap = MAP_FAILED;
  
    if ((fbfd = open("/dev/graphics/fb0", O_RDWR)) == -1) { 
      L("Cannot open fb device %s\n", framebuffer_device);
      sendMsgToGui("~SHOW|Cannot open fb device, please try out other display grab method\n");
      return -1;
    }
  
    update_fb_info();
  
  
    if (ioctl(fbfd, FBIOGET_FSCREENINFO, &amp;fscrinfo) != 0) {
      L("ioctl error\n");
      return -1;
    }
  
    L("line_lenght=%d xres=%d, yres=%d, xresv=%d, yresv=%d, xoffs=%d, yoffs=%d, bpp=%d\n",
      (int)fscrinfo.line_length,(int)scrinfo.xres, (int)scrinfo.yres,
      (int)scrinfo.xres_virtual, (int)scrinfo.yres_virtual,
      (int)scrinfo.xoffset, (int)scrinfo.yoffset,
      (int)scrinfo.bits_per_pixel);
  
    size_t size = scrinfo.yres_virtual;
    if (size &lt; scrinfo.yres * 2) {
      L("Using Droid workaround\n");
      size = scrinfo.yres * 2;
    }
  
    if ((scrinfo.bits_per_pixel == 24)) {
      scrinfo.bits_per_pixel = 32;
      L("24-bit XRGB display detected\n");
    }
  
    size_t fbSize = roundUpToPageSize(fscrinfo.line_length * size);
  
    fbmmap = mmap(NULL, fbSize , PROT_READ|PROT_WRITE ,  MAP_SHARED , fbfd, 0);
  
    if (fbmmap == MAP_FAILED) { 
      L("mmap failed\n");
      sendMsgToGui("~SHOW|Framebuffer mmap failed, please try out other display grab method\n");
      return -1;
    }
  
    return 1;
  }
  </code></pre>
  
  <p>it work good with xperia u but it return blackscreen with nexus 10 and samsung galaxy tab 3.
  can help me the way get buffer screen good than it ?</p>
  
  <p>Thank you</p>