Taking a Screen Shot of an Embedded Linux Framebuffer
Asked Answered
B

4

8

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?

Boxer answered 29/10, 2009 at 17:3 Comment(1)
Is "Embedded Linux" a very specific kernel version / configuration, or just a general name for Linux running on Embedded? Related: unix.stackexchange.com/questions/25063/…Tactics
C
11

Take a look at fbgrab, an application that does just that (it saves the framebuffer content as a png).

Constantine answered 8/12, 2009 at 20:47 Comment(2)
I tried out fbgrab, but it does not support "low-end bit depths". For my device the bit depth is 8. :( However, I looked at fbshot - sfires.net/fbshot. fbgrab is based on fbshot and it supports 8 bit depth. fbshot works just fine.Boxer
fbgrab has been moved to GitHub. I also had a problem with ancient version 1.2 which did not handle RGB565 well - fixed by update to the recent version.Overwhelm
C
7

You can simply capture the framebuffer to a file and open it in any raw image viewer or try online eg: https://rawpixels.net/

cat /dev/fb0 > fbdump
Chiou answered 11/2, 2020 at 10:13 Comment(3)
This online converter didn't work for me, but here I found a Perl script that did the conversion nicely: cnx-software.com/2010/07/18/how-to-do-a-framebuffer-screenshotPeoria
Is it normal to get several megabytes of all zero content from this way of dumping /dev/fb0 ?Ruphina
@matanster: a raw file like that is just every pixel in order. Since a terminal screen is mostly black, and black is #000, you are going to have a lot of zeros to represent black pixels.Orel
T
1

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:

Pixels are stored in memory in hardware-dependent formats. Applications need to be aware of the pixel storage format in order to write image data to the frame buffer memory in the format expected by the hardware.

Formats are described by frame buffer types and visuals. Some visuals require additional information, which are stored in the variable screen information bits_per_pixel, grayscale, red, green, blue and transp fields.

Visuals describe how color information is encoded and assembled to create macropixels. Types describe how macropixels are stored in memory. The following types and visuals are supported.

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.

Tactics answered 29/10, 2015 at 10:20 Comment(0)
B
0

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

Blasted answered 11/5, 2023 at 10:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.