作者:常德锦江-余欢 | 来源:互联网 | 2023-09-17 16:03
structfb_var_screeninfo{__u32xres;*visibleresolution横像素*__u32yres;竖像素__u32xres_virtual;*
struct fb_var_screeninfo {
__u32 xres; /* visible resolution横像素 */__u32 yres; //竖像素
__u32 xres_virtual; /* virtual resolution */__u32 yres_virtual;
__u32 xoffset; /* offset from virtual to visible */__u32 yoffset; /* resolution */
__u32 bits_per_pixel; /* guess what代表颜色深度 */__u32 grayscale; /* != 0 Graylevels instead of colors
*/
struct fb_bitfield red; /*
bitfield in fb mem if true color, */struct fb_bitfield green; /*
else only length is significant */struct fb_bitfield blue;
struct fb_bitfield transp; /*
transparency */
__u32 nonstd; /* != 0 Non standard pixel format */
__u32 activate; /* see FB_ACTIVATE_* */
__u32 height; /* height of picture in mm???
*/__u32 width; /* width of picture in mm????
*/
__u32 accel_flags; /* acceleration flags (hints) */
/* Timing: All values in pixclocks, except pixclock (of
course) */__u32 pixclock; /* pixel clock in ps (pico seconds) */__u32 left_margin; /* time from sync to picture */__u32 right_margin; /* time from picture to sync */__u32 upper_margin; /* time from sync to picture */__u32 lower_margin;
__u32 hsync_len; /* length of horizontal sync */__u32 vsync_len; /* length of vertical sync */__u32 sync; /* see FB_SYNC_* */__u32 vmode; /* see FB_VMODE_* */__u32 reserved[6]; /* Reserved for future compatibility
*/};前几个成员决定了分辨率。xres和yres是在屏幕上可见的实际分辨率,在通常的vga模式将为640和400(也许是480,by highbar)。*res-virtual决定了构建屏幕时视频卡读取屏幕内存的方式。当实际的垂直分辨率为400,虚拟分辨率可以是800。这意味着800行的数据被保存在了屏幕内存区中。因为只有400行可以被显示,决定从那一行开始显示就是你的事了。这个可以通过设置*offset来实现。给yoffset赋0将显示前400行,赋35将显示第36行到第435行,如此重复。这个功能在许多情形下非常方便实用。它可以用来做双缓冲。双缓冲就是你的程序分配了可以填充两个屏幕的内存。将offset设为0,将显示前400行(假设是标准的vga),同时可以秘密的在400行到799行构建另一个屏幕,当构建结束时,将yoffset设为400,新的屏幕将立刻显示出来。现在将开始在第一块内存区中构建下一个屏幕的数据,如此继续。这在动画中十分有用。rgb设置信息确实是0,8,16但显示就是bgr,不合逻辑
后打开fb,输出fbd->vinfo.red.offset,fbd->vinfo.green.offset,fbd->vinfo.blue.offset的值,发现偏移为16,8,0,与测试一致。看来问题就在这里了,修改了这里的offset应该就能实现修改rgb顺序了。于是进行测试
fbd->vinfo.red.offset=0;
fbd->vinfo.green.offset=8;
fbd->vinfo.blue.offset=16;
![](https://img-blog.csdn.net/20170604154316246?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMjUxNDc4OTc=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
From