开发学院手机开发Android 开发 Android操作framebuffer 阅读

Android操作framebuffer

 2010-05-31 14:42:00 来源:WEB开发网   
核心提示:printf("Error reading variable information.");exit(3);}printf("sizeof(unsigned short) = %d", sizeof(unsigned short));printf("%dx%d, %db

printf("Error reading variable information. ");

exit(3);

}

printf("sizeof(unsigned short) = %d ", sizeof(unsigned short));

printf("%dx%d, %dbpp ", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel );

printf("xoffset:%d, yoffset:%d, line_length: %d ", vinfo.xoffset, vinfo.yoffset, finfo.line_length );

// Figure out the size of the screen in bytes

screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;;

// Map the device to memory

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. ");

exit(4);

}

printf("The framebuffer device was mapped to memory successfully. ");

//set to black color first

memset(fbp, 0, screensize);

//draw rectangle

y = (vinfo.yres - guage_height) / 2 - 2; // Where we are going to put the pixel

for (x = step - 2; x < vinfo.xres - step + 2; x++) {

location = (x+vinfo.xoffset) * (vinfo.bits_per_pixel/8) +

(y+vinfo.yoffset) * finfo.line_length;

*((unsigned short int*)(fbp + location)) = 255;

}

y = (vinfo.yres + guage_height) / 2 + 2; // Where we are going to put the pixel

for (x = step - 2; x < vinfo.xres - step + 2; x++) {

location = (x+vinfo.xoffset) * (vinfo.bits_per_pixel/8) +

(y+vinfo.yoffset) * finfo.line_length;

*((unsigned short int*)(fbp + location)) = 255;

}

x = step - 2;

for (y = (vinfo.yres - guage_height) / 2 - 2; y < (vinfo.yres + guage_height) / 2 + 2; y++) {

location = (x+vinfo.xoffset) * (vinfo.bits_per_pixel/8) +

(y+vinfo.yoffset) * finfo.line_length;

*((unsigned short int*)(fbp + location)) = 255;

Tags:Android 操作 framebuffer

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接