根据这思路,操作framebuffer 显示图片和视频
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <string.h>
#include <unistd.h>
#include <linux/fb.h>int main(int argc, char *argv[])
{struct fb_var_screeninfo var;int fd_fb = open("/dev/fb0", O_RDWR);if (fd_fb < 0){puts("/dev/fb0 error");return -1;}if (ioctl(fd_fb, FBIOGET_VSCREENINFO, &var)){puts("ioctl error");return -1;}unsigned int line_width = var.xres * var.bits_per_pixel / 8;unsigned int pixel_width = var.bits_per_pixel / 8; //deepin=32int screen_size = var.xres * var.yres * var.bits_per_pixel / 8;unsigned char *fb_base = (unsigned char *)mmap(NULL, screen_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd_fb, 0);if (fb_base == NULL){puts("mmap error");return -1;}memset(fb_base, 0xff, screen_size);for (int i = 0; i < 1920; i++){int x=i;int y = var.yres / 2;int color = 0; //blockunsigned char *pen_8 = fb_base + y * line_width + x * pixel_width; unsigned int *pen_32 = (unsigned int *)pen_8; //char->int 这句非常重要*pen_32=color;}munmap(fb_base, screen_size);close(fd_fb);return 0;
}