我最近对一个奇怪的想法感到震惊,即从/ dev/urandom获取输入,将相关字符转换为随机整数,并使用这些整数作为像素的rgb/xy值绘制到屏幕上.
我做了一些研究(这里是关于StackOverflow和其他地方),许多人建议您可以直接写入/ dev/fb0,因为它是设备的文件表示.不幸的是,这似乎没有产生任何视觉上明显的结果.
我发现了一个示例C程序来自QT教程(不再可用),它使用mmap写入缓冲区.程序成功运行,但同样没有输出到屏幕.有趣的是,当我将我的笔记本电脑放入Suspend并稍后恢复时,我看到了一个瞬间闪现的图像(一个红色正方形),它被更早地写入帧缓冲区.写入帧缓冲区是否在Linux中用于绘制屏幕?理想情况下,我想写一个(ba)sh脚本,但C或类似的也可以.谢谢!
编辑:这是示例程序...兽医可能看起来很熟悉.
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
int main()
{
int fbfd = 0;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
long int screensize = 0;
char *fbp = 0;
int x = 0, y = 0;
long int location = 0;
// Open the file for reading and writing
fbfd = open("/dev/fb0", O_RDWR);
if (fbfd == -1) {
perror("Error: cannot open framebuffer device");
exit(1);
}
printf("The framebuffer …Run Code Online (Sandbox Code Playgroud)