Open main menu

DAVE Developer's Wiki β

Changes

XELK-AN-010: Capturing framebuffer screenshots

7,956 bytes added, 10:21, 25 August 2023
no edit summary
{{AppliesToAxelEsatta}}
{{AppliesToAxelLite}}
{{AppliesToAXEL Lite AN}}
{{AppliesToSMARX AN}}
{{AppliesToAXELULite}}
{{AppliesToAXEL ULite AN}}
{{AppliesToSBCLynx}}
{{AppliesTo SBC Lynx AN}}
{{InfoBoxBottom}}
| 1.0.0
| February 2021
|[[Axel_Embedded_Linux_Kit_(XELK)#XELK_4XELK_3.0.01|XELK 4.0.0]] , [[AXEL_ULite_and_SBC_Lynx_Embedded_Linux_Kit_(XUELK)#XUELK_23.0.1.2F2.0.2.2F2.0.3|XUELK 2.0.3]]
|-
|}
==Introduction==
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. <code>fbgrab<By using the well-known [https:/code> is a small utility that /imagemagick.org/ ImageMagick suite], this job can be used for this jobaccomplished straightforwardly. This Application Note (AN) shows how to use it on a system running a XELK-based Yocto Linux distribution.
==Installing <code>fbgrabImageMagick convert</code>==Assuming that root file system provides the [[XELK-AN-003:_Package_Management_with_Yocto|<code>smart</code> tool]]and it is set up properly, the <code>fbgrabImageMagick</code> utility package can be installed as follows:
<pre class="board-terminal">
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
</pre>
==Capturing screenshots==
The following examples refer to a system using a 1024x768 16bpp 1024x600 24bpp framebuffer, which is mapped to <code>/dev/fb0</code>.
When the display shows the image to be captured, to grab a "raw" screenshot and save it to file, issue the following command:
<pre class="board-terminal">
cat root@sznpc:~# dd if=/dev/fb0 > testof=screenshot.fbraw4800+0 records in4800+0 records out
</pre>
Then convert the raw data to a PNG image file, run by running the following command:
<pre class="board-terminal">
./fbgrab root@sznpc:~# convert -w 1024 size 1024x600 -h 768 -b 16 -l 1024 -f testdepth 8 rgba:screenshot.fb testraw screen0.pngConverting image from 16Now writing PNG file (compression -1)
</pre>
Alternatively, if the <code>fbgrabconvert</code> utility can not be installed onto the target's root filesystefilesystem, the raw data file <code>testscreenshot.fbraw</code> can be copied to a Linux host where <code>fbgrabconvert</code> is available.
It is also worth remembering that, if the screen parameters such as resolution or pixel depth are unknown, the [http://spblinux.de/2.0/doc/fbset.html <code>fbset</code> tool] can be used to display them:
<pre class="board-terminal">
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
</pre>
The numbers following <code>geometry</code> 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 <code>depth</code> parameter of <code>convert</code> was set to 8 and the format was set to <code>rgba</code>.
8,186
edits