Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

直接从framebuffer读取画面赋值到bitmap发现显示混乱 #113

Open
Tracker647 opened this issue Dec 9, 2024 · 3 comments
Open

Comments

@Tracker647
Copy link

Tracker647 commented Dec 9, 2024

环境为ubuntu 20虚拟机,在进程获取fb0数据赋值给bitmap输出到画面,发现显示混乱,但是在嵌入式机器上就没问题,对比下是line_length和xres不一致导致的(比如分辨率800x480, 理应line_length是3200,但是ubuntu 20虚拟机上的line length是6688对应xres_virtual=1672),但是fbset上又没办法改line_length, 改分辨率只是表面参数,没法解决这个

测试片段:

void update_g_bitmap_backgroud() {
	rect_t r = rect_init(0, 0, g_bitmap->w, g_bitmap->h);
	char *shared_data = LibFrameBufferGet(USE_FB_ID)->fbdata;  

	bitmap_t temp_bmp;
	bitmap_init(&temp_bmp, 800, 480, BITMAP_FMT_BGRA8888, shared_data);
	bitmap_save_png(&temp_bmp, "test.png");
	helper_bitmap_bgra8888_to_rgba8888(g_bitmap, &temp_bmp);
	bitmap_deinit(&temp_bmp);
}

虚拟机fb信息, 有参考vmware调试ubuntu的文档做了双缓存:

devices_load : path = file:///home/zhangdalin/AWStudioProjects/kp25sweb/process/Awtk_GamiWebDisplayStream/config/devices.json
devices[0]: path = /dev/fb0, type = fb
devices[1]: path = /dev/dri/card0, type = drm
fb_info_t: /dev/fb0
xres=800 yres=600
xres_virtual=1672 yres_virtual=1254
bits_per_pixel=32 line_length=6688
fb_info_t: red(16 8) green(8 8) blue(0 8)
xpanstep=1 ywrapstep=0
fb_size=4012800 fb_total_size=8386752 fb_nr=2 smem_len=8386752
fb_open clear
fb_open ok
run in vmware and fix FBIOPAN_DISPLAY block issue
=========fb_number=2
ratio=1.000000 800 600
ratio=1.000000 800 600
Build at: Dec  9 2024 22:34:41
LibFrameBufferCreate /dev/fb0
LibFrameBuffer: width 800 height: 600 bpp: 4
SIGPIPE ignore

左边是截图,右边是虚拟机fb显示:
image-20241210001708112
问awtk上有没有将fb还原到bitmap的方式?

@Tracker647
Copy link
Author

问题解决了,换到公司的电脑环境,ub虚拟机里面fb大小定死是1176x885, 之前做的逻辑,以为是截取800x480的平面,实际上是在1176x885的一维数组里面从0开始顺序读取了800x480的部分,这就解释了为什么出来是支离破碎的。

@Tracker647
Copy link
Author

bitmap_init对data数组是线性读取,不是按区域拷贝的,长眼了- -。。。

@xianjimli
Copy link
Member

试试:bitmap_set_line_length

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants