mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-10 04:37:55 +08:00
perf(GIF): Faster GIF library drop-in replacement (#8743)
Co-authored-by: André <andre_miguel_costa@hotmail.com>
This commit is contained in:
@@ -6,8 +6,8 @@ GIF Decoder
|
||||
|
||||
**GIF Decoder** is an LVGL extension that enables you to use GIF images in your LVGL UI.
|
||||
|
||||
For a detailed introduction, see: https://github.com/lecram/gifdec .
|
||||
|
||||
The implementation uses the `AnimatedGIF <https://github.com/bitbank2/AnimatedGIF/tree/master>`__
|
||||
library.
|
||||
|
||||
|
||||
Usage
|
||||
@@ -16,6 +16,22 @@ Usage
|
||||
Once enabled in ``lv_conf.h`` by setting :c:macro:`LV_USE_GIF` to ``1``,
|
||||
:cpp:expr:`lv_gif_create(parent)` can be used to create a gif widget.
|
||||
|
||||
Set the color format of the gif framebuffer with :cpp:expr:`lv_gif_set_color_format(widget, color_format)`.
|
||||
Use :cpp:enumerator:`LV_COLOR_FORMAT_ARGB8888` for gifs with transparency.
|
||||
It is set to :cpp:enumerator:`LV_COLOR_FORMAT_ARGB8888` by default.
|
||||
Significant RAM can be saved by using a smaller color format.
|
||||
A color format conversion can be saved during rendering if the color format matches the display
|
||||
color format.
|
||||
This function can be called before :cpp:func:`lv_gif_set_src` to prevent the initial default ARGB8888
|
||||
framebuffer from being allocated.
|
||||
|
||||
The supported color formats are:
|
||||
|
||||
- :cpp:enumerator:`LV_COLOR_FORMAT_RGB565`
|
||||
- :cpp:enumerator:`LV_COLOR_FORMAT_RGB565_SWAPPED`
|
||||
- :cpp:enumerator:`LV_COLOR_FORMAT_RGB888`
|
||||
- :cpp:enumerator:`LV_COLOR_FORMAT_ARGB8888`
|
||||
|
||||
:cpp:expr:`lv_gif_set_src(widget, src)` works very similarly to :cpp:func:`lv_image_set_src`.
|
||||
As source, it also accepts images as variables (:c:struct:`lv_image_dsc_t`) or files.
|
||||
|
||||
@@ -43,15 +59,12 @@ from files. To do so, follow the instructions in :ref:`file_system`.
|
||||
Memory Requirements
|
||||
*******************
|
||||
|
||||
To decode and display a GIF animation the following amount of RAM (in bytes) is
|
||||
required for each of the following color depths:
|
||||
|
||||
.. |times| unicode:: U+000D7 .. MULTIPLICATION SIGN
|
||||
|
||||
- :c:macro:`LV_COLOR_DEPTH` ``8``: 3 |times| image width |times| image height
|
||||
- :c:macro:`LV_COLOR_DEPTH` ``16``: 4 |times| image width |times| image height
|
||||
- :c:macro:`LV_COLOR_DEPTH` ``32``: 5 |times| image width |times| image height
|
||||
|
||||
To decode and display a GIF animation ~25 kB of RAM is needed plus
|
||||
(color format pixel size + 1) |times| image width |times| image height.
|
||||
RGB565 has a pixel size of 2, RGB888 has a pixel size of 3, and
|
||||
ARGB8888 has a pixel size of 4.
|
||||
|
||||
|
||||
.. _gif_example:
|
||||
|
||||
Reference in New Issue
Block a user