framebuffer 设置页面大小 尺寸


 
 
#include <stdio.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>
#include <stdlib.h.>
 
int main() {
int fb;
struct fb_var_screeninfo vinfo;
 
// 打开framebuffer设备
fb = open("/dev/fb0", O_RDWR);
if (fb < 0) {
perror("Error: cannot open framebuffer device");
exit(1);
}
 
// 读取当前的var信息
if (ioctl(fb, FBIOGET_VSCREENINFO, &vinfo)) {
perror("Error reading variable information");
exit(2);
}
 
// 设置新的分辨率大小
vinfo.xres = 1024; // 水平分辨率
vinfo.yres = 768; // 垂直分辨率
 
// 设置新的分辨率大小
if (ioctl(fb, FBIOPUT_VSCREENINFO, &vinfo)) {
perror("Error setting variable information");
exit(3);
}
 
printf("Screen size set to %dx%d\n", vinfo.xres, vinfo.yres);
 
close(fb);
return 0;
}

posted on   zxddesk  阅读(29)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2022-10-02 龙芯编译
2022-10-02 cannot autolaunch D-Bus without X11 $DISPLAY
2022-10-02 Slow boot - "a start job is running for dev-disk-by..."
2022-10-02 Linux下安装软件的3种方式

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示