拍摄嵌入式 Linux 帧缓冲区的屏幕截图
我在评估套件(Zoom OMAP35x Torpedo 开发套件)上运行嵌入式 Linux。该板有一个 LCD,我希望能够拍摄屏幕截图并将其转换为 gif 或 png。我可以通过执行以下操作来获取原始数据:“cp /dev/fb0 screen.raw”,但我对如何将图像转换为 gif 或 png 格式感到困惑。
我尝试使用 ImageMagick 的转换(例如:“convert -depth 8 -size 240x320 rgb:./screen.raw -swap 0,2 -separate -combine screen.png”),但无法获得看起来像的图像正确的。
有谁知道我可以尝试其他任何工具吗?或者有人有使用 ImageMagick 的技巧吗?
I'm running Embedded Linux on an evaluation kit (Zoom OMAP35x Torpedo Development Kit). The board has an LCD and I would like to be able to take screen shots convert them into a gif or png. I can get the raw data by doing the following: "cp /dev/fb0 screen.raw", but I am stumped on how to convert the image into a gif or png format.
I played around with convert from ImageMagick (example: "convert -depth 8 -size 240x320 rgb:./screen.raw -swap 0,2 -separate -combine screen.png"), but have been unable to get an image that looks right.
Does anyone know of any other tools that I could try out? Or does anyone have tips for using ImageMagick?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
看一下fbgrab,一个可以完成此任务的应用程序(它将帧缓冲区内容保存为 png)。
Take a look at fbgrab, an application that does just that (it saves the framebuffer content as a png).
您可以简单地将帧缓冲区捕获到文件中并在任何原始图像查看器中打开它或在线尝试,例如: https://rawpixels.net/
You can simply capture the framebuffer to a file and open it in any raw image viewer or try online eg: https://rawpixels.net/
直接使用 ImageMagick 可能不太可能/很容易做到这一点。
Linux 内核 4.2 文档 https://github。 com/torvalds/linux/blob/v4.2/Documentation/fb/api.txt#45 说:
下面是视觉效果和类型的列表,但描述不足以让我立即理解确切的格式。
但它似乎可能不是 ImageMagick 直接理解的格式,或者至少您必须找出使用的格式来决定 ImageMagick 选项。
It might not be possible / easy to do it directly with ImageMagick.
The Linux kernel 4.2 documentation https://github.com/torvalds/linux/blob/v4.2/Documentation/fb/api.txt#45 says:
A list of visuals and types follows, but the description is not enough for me to understand the exact formats immediately.
But it seems likely that it might not be a format that ImageMagick will understand directly, or at least you'd have to find out the used format to decide the ImageMagick options.
只需使用 cat 即可获取原始帧缓冲区数据
cat /dev/fb0 > fbdump.data
请注意,这是帧缓冲区设置的本机格式。
要转换它,ffmpeg 很有用。请记住使用
-s
设置大小,并使用-pix_fmt
设置像素格式ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgb32 -s 800x480 -i fbdump.data -f image2 -vcodec png snapshot.png
您还可以在 gimp 中打开
.data
文件,但格式选项更有限。最后,您还可以使用 fbgrab 获取屏幕截图并直接转换为 png 格式。也就是说,如果您的嵌入式目标有它。
fbgrab -d /dev/fb0 截图.png
Simply use cat to get the raw frame buffer data
cat /dev/fb0 > fbdump.data
Note that this is in the native format of whatever your frame buffer is set to.
To convert it ffmpeg is useful. Remember to set the size with
-s
and the pixel format with-pix_fmt
ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt rgb32 -s 800x480 -i fbdump.data -f image2 -vcodec png screenshot.png
You can also open
.data
files in gimp but the format options are more limited.lastly you can also use fbgrab to get a screenshot and convert directly to png format. That is, if your embedded target has it.
fbgrab -d /dev/fb0 screenshot.png