如何使用sample hifb.c进行图形界面开发
// 下面是样例代码 sample hifb.c
#include <stdio.h>
#include <fcntl.h>
#include <sys ioctl.h="">
#include <linux fb.h="">
#define DEVNAME "/dev/fb0"
int main(void) {
int fd;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
long int screensize;
char
int x, y;
long int location;
fd = open(DEVNAME, O_RDWR);
if (fd == -1) {
perror("Error: cannot open framebuffer device");
return 1;
}
printf("The framebuffer device was opened successfully.\n");
if (ioctl(fd, FBIOGET_VSCREENINFO, &vinfo)) {
perror("Error: failed to get variable screen information");
return 1;
}
if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo)) {
perror("Error: failed to get fixed screen information");
return 1;
}
screensize = vinfo.xres
fbp = (char
if ((int)fbp == -1) {
perror("Error: failed to map framebuffer device to memory");
return 1;
}
printf("The framebuffer device was mapped to memory successfully.\n");
for (y = 0; y < vinfo.yres; y++) {
for (x = 0; x < vinfo.xres; x++) {
location = (x + vinfo.xoffset)
if (vinfo.bits_per_pixel == 32) {
// 红色
// 绿色
// 蓝色
// 透明度
} else { // 少于32位的像素格式
}
}
}
munmap(fbp, screensize);
close(fd);
return 0;
}
</linux></sys></fcntl.h></stdio.h>
暂无评论