XELK-AN-010: Capturing framebuffer screenshots

From DAVE Developer's Wiki
Revision as of 15:17, 4 February 2021 by U0001 (talk | contribs)

Jump to: navigation, search
Info Box
Axel-04.png Applies to Axel Ultra
Axel-02.png Applies to AXEL ESATTA
Axel-lite 02.png Applies to Axel Lite
AXEL ULite-top.png Applies to AXEL ULite
SBC Lynx-top.png Applies to SBC Lynx


200px-Emblem-important.svg.png

This application note has been validated using the kit version in the History table.

History[edit | edit source]

Version Date Development Kit version
1.0.0 February 2021 XELK 3.0.0 ,

Introduction[edit | edit source]

In certain situations, it is necessary and/or convenient to grab a screenshot of the full display from the framebuffer directly, for example for debugging purposes or documentation. By using the well-known ImageMagick tool, this job can be accomplished straightforwardly. This Application Note (AN) shows how to use it on a system running a XELK-based Yocto Linux distribution.

Installing fbgrab[edit | edit source]

Assuming that root file system provides the smart tool, the fbgrab utility can be installed as follows:


Capturing screenshots[edit | edit source]

The following examples refer to a system using a 1024x600 24bpp framebuffer, which is mapped to /dev/fb0.

When the display shows the image to be captured, to grab a "raw" screenshot and save it to file, issue the following command:

root@sznpc:~# dd if=/dev/fb0 of=screenshot.raw
4800+0 records in
4800+0 records out

Then convert the raw data to a PNG image file, run the following command:

root@sznpc:~# convert -size 1024x600 -depth 8 rgba:screenshot.raw screen0.png

Alternatively, if the convert utility can not be installed onto the target's root filesystem, the raw data file screenshot.raw can be copied to a Linux host where convert is available.

It is also worth remembering that, if the screen parameters such as resolution or pixel depth are unknown, the fbset tool can be used to display them:

root@sznpc:~# fbset

mode "1024x600-67"
        # D: 51.201 MHz, H: 43.538 kHz, V: 67.085 Hz
        geometry 1024 600 1024 600 32
        timings 19531 104 43 24 20 5 5
        accel false
        rgba 8/16,8/8,8/0,8/24
endmode

The numbers following geometry indicate the resolution (1024x600) and the bits required to represent a pixel (32). In this case, 8 bits are used for each channel (reg, green, blue, and alpha) resulting in 32 bits combined. That is why the depth parameter of convert was set to 8.