Reputation: 4339
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?
Upvotes: 8
Views: 21725
Reputation: 166
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
Upvotes: 0
Reputation: 1198
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
Upvotes: 7
Reputation: 266
Take a look at fbgrab, an application that does just that (it saves the framebuffer content as a png).
Upvotes: 11
Reputation: 382802
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.
Upvotes: 1