Difference between revisions of "XELK-AN-010: Capturing framebuffer screenshots"

From DAVE Developer's Wiki
Jump to: navigation, search
(Capturing screenshots)
(9 intermediate revisions by one other user not shown)
Line 3: Line 3:
 
{{AppliesToAxelEsatta}}
 
{{AppliesToAxelEsatta}}
 
{{AppliesToAxelLite}}
 
{{AppliesToAxelLite}}
 +
{{AppliesToAXEL Lite AN}}
 
{{AppliesToSMARX AN}}
 
{{AppliesToSMARX AN}}
 
{{AppliesToAXELULite}}
 
{{AppliesToAXELULite}}
 +
{{AppliesToAXEL ULite AN}}
 
{{AppliesToSBCLynx}}
 
{{AppliesToSBCLynx}}
 +
{{AppliesTo SBC Lynx AN}}
 
{{InfoBoxBottom}}
 
{{InfoBoxBottom}}
  
Line 18: Line 21:
 
| 1.0.0
 
| 1.0.0
 
| February 2021
 
| February 2021
|[[Axel_Embedded_Linux_Kit_(XELK)#XELK_3.0.1|XELK 3.0.1]]
+
|[[Axel_Embedded_Linux_Kit_(XELK)#XELK_4.0.0|XELK 4.0.0]] , [[AXEL_ULite_and_SBC_Lynx_Embedded_Linux_Kit_(XUELK)#XUELK_2.0.1.2F2.0.2.2F2.0.3|XUELK 2.0.3]]
 
|-
 
|-
 
|}
 
|}
  
 
==Introduction==
 
==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. By using the well-known [https://imagemagick.org/ 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.
+
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</code> is a small utility that can be used for this job. This Application Note (AN) shows how to use it on a system running a XELK-based Yocto Linux distribution.
  
==Installing <code>ImageMagick convert</code>==
+
==Installing <code>fbgrab</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>ImageMagick</code> package can be installed as follows:
+
Assuming that root file system provides the [[XELK-AN-003:_Package_Management_with_Yocto|<code>smart</code> tool]], the <code>fbgrab</code> utility can be installed as follows:
  
 
<pre class="board-terminal">
 
<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>
 
</pre>
  
 
==Capturing screenshots==
 
==Capturing screenshots==
The following examples refer to a system using a 1024x600 24bpp framebuffer, which is mapped to <code>/dev/fb0</code>.
+
The following examples refer to a system using a 1024x768 16bpp 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:
 
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">
 
<pre class="board-terminal">
root@sznpc:~# dd if=/dev/fb0 of=screenshot.raw
+
cat /dev/fb0 > test.fb
4800+0 records in
 
4800+0 records out
 
 
</pre>
 
</pre>
  
Then convert the raw data to a PNG image file by running the following command:
+
Then convert the raw data to a PNG image file, run the following command:
 
<pre class="board-terminal">
 
<pre class="board-terminal">
root@sznpc:~# convert -size 1024x600 -depth 8 rgba:screenshot.raw screen0.png
+
./fbgrab -w 1024 -h 768 -b 16 -l 1024 -f test.fb test.png
 +
Converting image from 16
 +
Now writing PNG file (compression -1)
 
</pre>
 
</pre>
  
Alternatively, if the <code>convert</code> utility can not be installed onto the target's root filesystem, the raw data file <code>screenshot.raw</code> can be copied to a Linux host where <code>convert</code> is available.
+
Alternatively, the raw data file <code>test.fb</code> can be copied to a Linux host where <code>fbgrab</code> is installed.
  
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:
+
It is worth remembering that, if the resolution and/or pixel depth are unknown, the [http://spblinux.de/2.0/doc/fbset.html <code>fbset</code> tool] can be used to display such parameters:
 
<pre class="board-terminal">
 
<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>
 
</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>.
 

Revision as of 17:18, 3 February 2021

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 4.0.0 , XUELK 2.0.3

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. fbgrab is a small utility that can be used for this job. 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 1024x768 16bpp 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:

cat /dev/fb0 > test.fb

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

./fbgrab -w 1024 -h 768 -b 16 -l 1024 -f test.fb test.png
Converting image from 16
Now writing PNG file (compression -1)

Alternatively, the raw data file test.fb can be copied to a Linux host where fbgrab is installed.

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