XELK-AN-010: Capturing framebuffer screenshots

From DAVE Developer's Wiki
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.1

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 suite, 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 ImageMagick convert[edit | edit source]

Assuming that root file system provides the smart tool and it is set up properly, the ImageMagick package can be installed as follows:

root@sznpc:~# smart install imagemagick
Loading cache...
Updating cache...                                             ###################################################################################### [100%]

Computing transaction...

Installing packages (11):
  imagemagick-6.9.2-r0@cortexa9hf_neon  libice6-1:1.0.9-r0@cortexa9hf_neon    libxau6-1:1.0.8-r0@cortexa9hf_neon    libxext6-1:1.3.3-r0@cortexa9hf_neon   
  lcms-2.7-r0@cortexa9hf_neon           libsm6-1:1.2.2-r0@cortexa9hf_neon     libxcb1-1.11.1-r0@cortexa9hf_neon     libxt6-1:1.1.5-r0@cortexa9hf_neon     
  libfftw-3.3.4-r0@cortexa9hf_neon      libx11-6-1:1.6.3-r0@cortexa9hf_neon   libxdmcp6-1:1.1.2-r0@cortexa9hf_neon  

3.8MB of package files are needed. 8.7MB will be used.

Confirm changes? (Y/n): y

[  410.232039] rtc-pcf2127-i2c 1-0051: low voltage detected, check/replace RTC battery.
Fetching packages...                                                                                                                                       
-> http://yocto.dave.eu/xelk-3.0.0/cortexa9hf_neon/libxcb1-1.11.1-r0.cortexa9hf_neon.rpm                                                                   
-> http://yocto.dave.eu/xelk-3.0.0/cortexa9hf_neon/libice6-1.0.9-r0.cortexa9hf_neon.rpm                                                                    
libice6-1.0.9-r0.cortexa9hf_neon.rpm                          ###################################################################################### [  9%]
libxcb1-1.11.1-r0.cortexa9hf_neon.rpm                         ###################################################################################### [ 18%]
-> http://yocto.dave.eu/xelk-3.0.0/cortexa9hf_neon/lcms-2.7-r0.cortexa9hf_neon.rpm                                                                         
-> http://yocto.dave.eu/xelk-3.0.0/cortexa9hf_neon/libsm6-1.2.2-r0.cortexa9hf_neon.rpm                                                                     
libsm6-1.2.2-r0.cortexa9hf_neon.rpm                           ###################################################################################### [ 27%]
-> http://yocto.dave.eu/xelk-3.0.0/cortexa9hf_neon/libxt6-1.1.5-r0.cortexa9hf_neon.rpm                                                                     
libxt6-1.1.5-r0.cortexa9hf_neon.rpm                           ###################################################################################### [ 36%]
-> http://yocto.dave.eu/xelk-3.0.0/cortexa9hf_neon/libxext6-1.3.3-r0.cortexa9hf_neon.rpm                                                                   
libxext6-1.3.3-r0.cortexa9hf_neon.rpm                         ###################################################################################### [ 45%]
-> http://yocto.dave.eu/xelk-3.0.0/cortexa9hf_neon/libxdmcp6-1.1.2-r0.cortexa9hf_neon.rpm                                                                  
libxdmcp6-1.1.2-r0.cortexa9hf_neon.rpm                        ###################################################################################### [ 54%]
-> http://yocto.dave.eu/xelk-3.0.0/cortexa9hf_neon/libxau6-1.0.8-r0.cortexa9hf_neon.rpm                                                                    
libxau6-1.0.8-r0.cortexa9hf_neon.rpm                          ###################################################################################### [ 63%]
lcms-2.7-r0.cortexa9hf_neon.rpm                               ###################################################################################### [ 72%]
-> http://yocto.dave.eu/xelk-3.0.0/cortexa9hf_neon/libx11-6-1.6.3-r0.cortexa9hf_neon.rpm                                                                   
-> http://yocto.dave.eu/xelk-3.0.0/cortexa9hf_neon/libfftw-3.3.4-r0.cortexa9hf_neon.rpm                                                                    
libfftw-3.3.4-r0.cortexa9hf_neon.rpm                          ###################################################################################### [ 81%]
libx11-6-1.6.3-r0.cortexa9hf_neon.rpm                         ###################################################################################### [ 90%]
-> http://yocto.dave.eu/xelk-3.0.0/cortexa9hf_neon/imagemagick-6.9.2-r0.cortexa9hf_neon.rpm                                                                
imagemagick-6.9.2-r0.cortexa9hf_neon.rpm                      ###################################################################################### [100%]

                                                                                                                                                           
Committing transaction...
Preparing...                                                  ###################################################################################### [  0%]
   1:Installing libice6                                       ###################################################################################### [  9%]
   2:Installing lcms                                          ###################################################################################### [ 18%]
   3:Installing libxdmcp6                                     ###################################################################################### [ 27%]
   4:Installing libfftw                                       ###################################################################################### [ 36%]
   5:Installing libxau6                                       ###################################################################################### [ 45%]
   6:Installing libsm6                                        ###################################################################################### [ 54%]
   7:Installing libxcb1                                       ###################################################################################### [ 63%]
   8:Installing libx11-6                                      ###################################################################################### [ 72%]
   9:Installing libxt6                                        ###################################################################################### [ 81%]
  10:Installing libxext6                                      ###################################################################################### [ 90%]
  11:Installing imagemagick                                   ###################################################################################### [100%]
Output from imagemagick-6.9.2-r0@cortexa9hf_neon:                              
update-alternatives: Linking /usr/bin/animate to /usr/bin/animate.im6          
update-alternatives: Linking /usr/bin/compare to /usr/bin/compare.im6
update-alternatives: Linking /usr/bin/composite to /usr/bin/composite.im6
update-alternatives: Linking /usr/bin/conjure to /usr/bin/conjure.im6
update-alternatives: Linking /usr/bin/convert to /usr/bin/convert.im6
update-alternatives: Linking /usr/bin/display to /usr/bin/display.im6
update-alternatives: Linking /usr/bin/identify to /usr/bin/identify.im6
update-alternatives: Linking /usr/bin/import to /usr/bin/import.im6
update-alternatives: Linking /usr/bin/mogrify to /usr/bin/mogrify.im6
update-alternatives: Linking /usr/bin/montage to /usr/bin/montage.im6
update-alternatives: Linking /usr/bin/stream to /usr/bin/stream.im6

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 by running 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). The last line tells the pixel format (RGBA). 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 and the format was set to rgba.