How to get RGB pixel values from Linux framebuffer?
问题 I want to get RGB values of screen pixels in the most efficient way, using Linux. So I decided to use the framebuffer library in C ( fb.h ) to access the framebuffer device ( /dev/fb0 ) and read from it directly. This is the code: #include <stdint.h> #include <linux/fb.h> #include <fcntl.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <sys/ioctl.h> #include <sys/mman.h> int main() { int fb_fd; struct fb_fix_screeninfo finfo; struct fb_var_screeninfo vinfo; uint8_t *fb_p