资源简介
linux fb-test-帧缓冲 两个例子(完整源代码),在Ubuntu上实验通过。

代码片段和文件信息
#if 0
#include
#include
#include
#include
#include
#include
int main()
{
int fbfd = 0;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
long int screensize = 0;
char *fbp = 0;
int x = 0 y = 0;
long int location = 0;
fbfd = open(“/dev/fb0“ O_RDWR);
if (!fbfd) {
printf(“Error: cannot open framebuffer device.\n“);
exit(1);
}
printf(“The framebuffer device was opened successfully.\n“);
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(“%dx%d %dbpp\n“ vinfo.xres vinfo.yres vinfo.bits_per_pixel );
screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
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(“lsq--1->The framebuffer device was mapped to memory successfully.\n“);
x = 100;
y = 100;
for ( y = 100; y < 300; y++ )
for ( x = 100; x < 300; x++ ) {
location = (x + vinfo.xoffset) * (vinfo.bits_per_pixel / 8) +
(y + vinfo.yoffset) * finfo.line_length;
if ( vinfo.bits_per_pixel == 32 ) {
*(fbp + location) = 100;
*(fbp + location + 1) = 15 + (x - 100) / 2;
*(fbp + location + 2) = 200 - (y - 100) / 5;
*(fbp + location + 3) = 0;
} else {
int b = 10;
int g = (x - 100) / 6;
int r = 31 - (y - 100) / 16;
unsigned short int t = r << 11 | g << 5 | b;
*((unsigned short int*)(fbp + location)) = t;
}
}
munmap(fbp screensize);
close(fbfd);
printf(“lsq--2-> close(fbfd).\n“);
return 0;
}
#endif
#include
#include
#include
#include
#include
#include
#include
int main()
{
int fbfd = 0;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
long int screensize = 0;
char *fbp = 0;
int x = 0 y = 0;
long int location = 0;
int startx=0 starty=0;
int width height;
// Open the file for reading and writing
fbfd = open(“/dev/fb0“ O_RDWR);
if (fbfd == -1) {
perror(“Error: cannot open framebuffer device“);
exit(1);
}
printf(“The framebuffer device was opened successfully.\n“);
// Get fixed screen information
if (ioctl(fbfd FBIOGET_FSCREENINFO &finfo) == -1) {
perror(“Error reading fixed information“);
exit(2);
}
// Get variable sc
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4925 2017-05-12 15:23 linux fb-test-帧缓冲 两个例子(完整源代码)\fb-test1.c
文件 1945 2017-05-12 15:16 linux fb-test-帧缓冲 两个例子(完整源代码)\fb-tst2.c
文件 13224 2017-05-12 15:23 linux fb-test-帧缓冲 两个例子(完整源代码)\test1
文件 9344 2017-05-12 15:22 linux fb-test-帧缓冲 两个例子(完整源代码)\test2
文件 724 2017-05-12 16:03 linux fb-test-帧缓冲 两个例子(完整源代码)\在Ubuntu16.04系统下测试帧缓冲(fr
目录 0 2017-06-18 18:05 linux fb-test-帧缓冲 两个例子(完整源代码)
----------- --------- ---------- ----- ----
30162 6
- 上一篇:usb3.0_fpga_ddr2原理图
- 下一篇:二层交换机测试方案
相关资源
- uboot到linux logo显示不间断 补丁
- UNIX/LINUX编程实践教程的源码
- Linux任务管理器
- linux应用层的华容道游戏源代码
- ubuntu9.10 可加载内核模块和字符设备驱
- MP3文件ID3v2ID3v2APEv2标签读取
- 操作系统实验——虚存管理实验
- linux下的发包工具sendip
- 尚观培训linux许巍关于c 的笔记和讲义
- 尚观培训linux董亮老师关于数据结构的
- linux 线程池源码 c 版
- linux C 电梯程序练习
- linux下用多进程同步方法解决生产者
- Linux 操作系统实验(全)
- Linux From Scratch 中文手册
- linux 网络实验 ftp程序
- Linux命令大全离线版&在线版
- 操作系统共享内存实验
- dos 下运行Linux 命令--gnu_utils
- linux 0.12内核源代码
- linux简易shell C实现
- linux实验报告及心得体会
- 基于GTK的Linux环境下的简易任务管理器
- linux扫雷游戏代码
- CAN Linux驱动代码
- Linux系统教材
- Thermal stability and glass-forming ability of
- intel 82579LM 网卡驱动Linux系统版 v1.9.
- SA1110处理器掌上电脑液晶显示器设计
- 基于Linux的串口服务器设计
评论
共有 条评论