mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-28 05:26:18 +08:00
chore: code and documentation cleanups, renames and fixes (#4607)
This commit is contained in:
@@ -55,13 +55,6 @@ menu "LVGL configuration"
|
|||||||
bool "Use cache to speed up getting object style properties"
|
bool "Use cache to speed up getting object style properties"
|
||||||
default y
|
default y
|
||||||
|
|
||||||
config LV_COLOR_CHROMA_KEY_HEX
|
|
||||||
hex "Images pixels with this color will not be drawn (if they are chroma keyed)."
|
|
||||||
range 0x000000 0xFFFFFF
|
|
||||||
default 0x00FF00
|
|
||||||
help
|
|
||||||
See misc/lv_color.h for some color values examples.
|
|
||||||
|
|
||||||
config LV_USE_OBJ_ID
|
config LV_USE_OBJ_ID
|
||||||
bool "Add id field to obj."
|
bool "Add id field to obj."
|
||||||
default n
|
default n
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ static uint32_t anim_ori_timer_period;
|
|||||||
LV_IMAGE_DECLARE(img_benchmark_cogwheel_argb);
|
LV_IMAGE_DECLARE(img_benchmark_cogwheel_argb);
|
||||||
#endif
|
#endif
|
||||||
LV_IMAGE_DECLARE(img_benchmark_cogwheel_rgb);
|
LV_IMAGE_DECLARE(img_benchmark_cogwheel_rgb);
|
||||||
LV_IMAGE_DECLARE(img_benchmark_cogwheel_chroma_keyed);
|
|
||||||
LV_IMAGE_DECLARE(img_benchmark_cogwheel_indexed16);
|
LV_IMAGE_DECLARE(img_benchmark_cogwheel_indexed16);
|
||||||
LV_IMAGE_DECLARE(img_benchmark_cogwheel_alpha256);
|
LV_IMAGE_DECLARE(img_benchmark_cogwheel_alpha256);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -107,7 +107,7 @@ Architecture
|
|||||||
~~~~~~~~~~~~
|
~~~~~~~~~~~~
|
||||||
|
|
||||||
- |uncheck| Add more feature to key presses (long press, release, etc).
|
- |uncheck| Add more feature to key presses (long press, release, etc).
|
||||||
- |uncheck| `lv_img_set_src()` use “type-aware” parameter and rework image decoders.
|
- |uncheck| `lv_image_set_src()` use “type-aware” parameter and rework image decoders.
|
||||||
(see `here <https://github.com/lvgl/lvgl/tree/arch/img-decode-rework>`__)
|
(see `here <https://github.com/lvgl/lvgl/tree/arch/img-decode-rework>`__)
|
||||||
- |uncheck| `C++ binding <https://github.com/lvgl/lv_binding_cpp>`__
|
- |uncheck| `C++ binding <https://github.com/lvgl/lv_binding_cpp>`__
|
||||||
- |uncheck| Markup language #2428
|
- |uncheck| Markup language #2428
|
||||||
|
|||||||
+2
-2
@@ -13,7 +13,7 @@ sources. For example:
|
|||||||
|
|
||||||
.. code:: c
|
.. code:: c
|
||||||
|
|
||||||
lv_img_set_src(my_img, "S:path/to/picture.bmp");
|
lv_image_set_src(my_img, "S:path/to/picture.bmp");
|
||||||
|
|
||||||
Note that, a file system driver needs to registered to open images from
|
Note that, a file system driver needs to registered to open images from
|
||||||
files. Read more about it :ref:`file-system` or just
|
files. Read more about it :ref:`file-system` or just
|
||||||
@@ -23,7 +23,7 @@ Limitations
|
|||||||
-----------
|
-----------
|
||||||
|
|
||||||
- Only BMP files are supported and BMP images as C array
|
- Only BMP files are supported and BMP images as C array
|
||||||
(:c:struct:`lv_img_dsc_t`) are not. It's because there is no practical
|
(:c:struct:`lv_image_dsc_t`) are not. It's because there is no practical
|
||||||
differences between how the BMP files and LVGL's image format stores
|
differences between how the BMP files and LVGL's image format stores
|
||||||
the image data.
|
the image data.
|
||||||
- BMP files can be loaded only from file. If you want to store them in
|
- BMP files can be loaded only from file. If you want to store them in
|
||||||
|
|||||||
+2
-2
@@ -8,8 +8,8 @@ https://github.com/lecram/gifdec
|
|||||||
When enabled in ``lv_conf.h`` with :c:macro:`LV_USE_GIF`
|
When enabled in ``lv_conf.h`` with :c:macro:`LV_USE_GIF`
|
||||||
:c:expr:`lv_gif_create(parent)` can be used to create a gif widget.
|
:c:expr:`lv_gif_create(parent)` can be used to create a gif widget.
|
||||||
|
|
||||||
:c:expr:`lv_gif_set_src(obj, src)` works very similarly to :c:func:`lv_img_set_src`.
|
:c:expr:`lv_gif_set_src(obj, src)` works very similarly to :c:func:`lv_image_set_src`.
|
||||||
As source, it also accepts images as variables (:c:struct:`lv_img_dsc_t`) or
|
As source, it also accepts images as variables (:c:struct:`lv_image_dsc_t`) or
|
||||||
files.
|
files.
|
||||||
|
|
||||||
Convert GIF files to C array
|
Convert GIF files to C array
|
||||||
|
|||||||
+3
-3
@@ -30,13 +30,13 @@ Overview
|
|||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
|
|
||||||
If enabled in ``lv_conf.h`` by :c:macro:`LV_USE_SJPG` LVGL will register a new
|
If enabled in ``lv_conf.h`` by :c:macro:`LV_USE_TJPGD` LVGL will register a new
|
||||||
image decoder automatically so JPG and SJPG files can be directly used
|
image decoder automatically so JPG and SJPG files can be used directly
|
||||||
as image sources. For example:
|
as image sources. For example:
|
||||||
|
|
||||||
.. code:: c
|
.. code:: c
|
||||||
|
|
||||||
lv_img_set_src(my_img, "S:path/to/picture.jpg");
|
lv_image_set_src(my_img, "S:path/to/picture.jpg");
|
||||||
|
|
||||||
Note that, a file system driver needs to registered to open images from
|
Note that, a file system driver needs to registered to open images from
|
||||||
files. Read more about it :ref:`file-system` or just
|
files. Read more about it :ref:`file-system` or just
|
||||||
|
|||||||
+14
-11
@@ -2,29 +2,32 @@
|
|||||||
Snapshot
|
Snapshot
|
||||||
========
|
========
|
||||||
|
|
||||||
Snapshot provides APIs to take snapshot image for LVGL object together
|
Snapshot provides API to take snapshot image for LVGL object together
|
||||||
with its children. The image will look exactly like the object.
|
with its children. The image will look exactly like the object on display.
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
|
|
||||||
Simply call API :c:func:`lv_snapshot_take` to generate the image descriptor
|
Simply call API :c:func:`lv_snapshot_take` to generate the image descriptor
|
||||||
which can be set as image object src using :c:func:`lv_img_set_src`.
|
which can be set as image object src using :c:func:`lv_image_set_src`.
|
||||||
|
|
||||||
Note, only below color formats are supported for now: -
|
Note, only following color formats are supported for now:
|
||||||
LV_IMG_CF_TRUE_COLOR - LV_IMG_CF_TRUE_COLOR_ALPHA - LV_IMG_CF_ALPHA_8BIT
|
- LV_COLOR_FORMAT_RGB565
|
||||||
|
- LV_COLOR_FORMAT_RGB888
|
||||||
|
- LV_COLOR_FORMAT_XRGB8888
|
||||||
|
- LV_COLOR_FORMAT_ARGB8888
|
||||||
|
|
||||||
Free the Image
|
Free the Image
|
||||||
~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~
|
||||||
|
|
||||||
The memory :c:func:`lv_snapshot_take` uses are dynamically allocated using
|
The memory :c:func:`lv_snapshot_take` uses are dynamically allocated using
|
||||||
:c:func:`lv_mem_alloc`. Use API :c:func:`lv_snapshot_free` to free the memory it
|
:c:func:`lv_malloc`. Use API :c:func:`lv_snapshot_free` to free the memory it
|
||||||
takes. This will firstly free memory the image data takes, then the
|
takes. This will firstly free memory the image data takes, then the
|
||||||
image descriptor.
|
image descriptor.
|
||||||
|
|
||||||
Take caution to free the snapshot but not delete the image object.
|
Take caution to free the snapshot but not delete the image object.
|
||||||
Before free the memory, be sure to firstly unlink it from image object,
|
Before free the memory, be sure to firstly unlink it from image object,
|
||||||
using :c:expr:`lv_img_set_src(NULL)` and :c:expr:`lv_img_cache_invalidate_src(src)`.
|
using :c:expr:`lv_image_set_src(NULL)` and :c:expr:`lv_cache_invalidate(lv_cache_find(src, LV_CACHE_SRC_TYPE_PTR, 0, 0));`.
|
||||||
|
|
||||||
Below code snippet explains usage of this API.
|
Below code snippet explains usage of this API.
|
||||||
|
|
||||||
@@ -32,19 +35,19 @@ Below code snippet explains usage of this API.
|
|||||||
|
|
||||||
void update_snapshot(lv_obj_t * obj, lv_obj_t * img_snapshot)
|
void update_snapshot(lv_obj_t * obj, lv_obj_t * img_snapshot)
|
||||||
{
|
{
|
||||||
lv_img_dsc_t* snapshot = (void*)lv_img_get_src(img_snapshot);
|
lv_image_dsc_t* snapshot = (void*)lv_image_get_src(img_snapshot);
|
||||||
if(snapshot) {
|
if(snapshot) {
|
||||||
lv_snapshot_free(snapshot);
|
lv_snapshot_free(snapshot);
|
||||||
}
|
}
|
||||||
snapshot = lv_snapshot_take(obj, LV_IMG_CF_TRUE_COLOR_ALPHA);
|
snapshot = lv_snapshot_take(obj, LV_COLOR_FORMAT_ARGB8888);
|
||||||
lv_img_set_src(img_snapshot, snapshot);
|
lv_image_set_src(img_snapshot, snapshot);
|
||||||
}
|
}
|
||||||
|
|
||||||
Use Existing Buffer
|
Use Existing Buffer
|
||||||
~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
If the snapshot needs update now and then, or simply caller provides memory, use API
|
If the snapshot needs update now and then, or simply caller provides memory, use API
|
||||||
``lv_res_t lv_snapshot_take_to_buf(lv_obj_t * obj, lv_img_cf_t cf, lv_img_dsc_t * dsc, void * buf, uint32_t buff_size)``
|
``lv_result_t lv_snapshot_take_to_buf(lv_obj_t * obj, lv_color_format_t cf, lv_image_dsc_t * dsc, void * buf, uint32_t buff_size);``
|
||||||
for this case. It's caller's responsibility to alloc/free the memory.
|
for this case. It's caller's responsibility to alloc/free the memory.
|
||||||
|
|
||||||
If snapshot is generated successfully, the image descriptor is updated
|
If snapshot is generated successfully, the image descriptor is updated
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ The background color is a simple color to fill the display. It can be
|
|||||||
adjusted with :cpp:expr:`lv_obj_set_style_bg_color(obj, color)`;
|
adjusted with :cpp:expr:`lv_obj_set_style_bg_color(obj, color)`;
|
||||||
|
|
||||||
The display background image is a path to a file or a pointer to an
|
The display background image is a path to a file or a pointer to an
|
||||||
:cpp:struct:`lv_img_dsc_t` variable (converted image data) to be used as
|
:cpp:struct:`lv_image_dsc_t` variable (converted image data) to be used as
|
||||||
wallpaper. It can be set with :cpp:expr:`lv_obj_set_style_bg_img_src(obj, &my_img)`;
|
wallpaper. It can be set with :cpp:expr:`lv_obj_set_style_bg_img_src(obj, &my_img)`;
|
||||||
If a background image is configured the background won't be filled with
|
If a background image is configured the background won't be filled with
|
||||||
``bg_color``.
|
``bg_color``.
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ bullet symbol (U+2022) and the built-in symbols (see below).
|
|||||||
Special fonts
|
Special fonts
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
- :c:macro:`LV_FONT_MONTSERRAT_12_SUBPX`: Same as normal 12 px font but with `subpixel rendering <#subpixel-rendering>`__
|
|
||||||
- :c:macro:`LV_FONT_MONTSERRAT_28_COMPRESSED`: Same as normal 28 px font but stored as a `compressed font <#compress-fonts>`__ with 3 bpp
|
- :c:macro:`LV_FONT_MONTSERRAT_28_COMPRESSED`: Same as normal 28 px font but stored as a `compressed font <#compress-fonts>`__ with 3 bpp
|
||||||
- :c:macro:`LV_FONT_DEJAVU_16_PERSIAN_HEBREW`: 16 px font with normal range + Hebrew, Arabic, Persian letters and all their forms
|
- :c:macro:`LV_FONT_DEJAVU_16_PERSIAN_HEBREW`: 16 px font with normal range + Hebrew, Arabic, Persian letters and all their forms
|
||||||
- :c:macro:`LV_FONT_SIMSUN_16_CJK`: 16 px font with normal range plus 1000 of the most common CJK radicals
|
- :c:macro:`LV_FONT_SIMSUN_16_CJK`: 16 px font with normal range plus 1000 of the most common CJK radicals
|
||||||
|
|||||||
+75
-91
@@ -54,12 +54,10 @@ Color formats
|
|||||||
Various built-in color formats are supported:
|
Various built-in color formats are supported:
|
||||||
|
|
||||||
- :cpp:enumerator:`LV_COLOR_FORMAT_NATIVE`: Simply stores the RGB colors (in whatever color depth LVGL is configured for).
|
- :cpp:enumerator:`LV_COLOR_FORMAT_NATIVE`: Simply stores the RGB colors (in whatever color depth LVGL is configured for).
|
||||||
- :cpp:enumerator:`LV_COLOR_FORMAT_NATIVE_ALPHA`: Like :cpp:enumerator:`LV_COLOR_FORMAT_NATIVE` but it also adds an alpha (transparency) byte for every pixel.
|
- :cpp:enumerator:`LV_COLOR_FORMAT_NATIVE_WITH_ALPHA`: Like :cpp:enumerator:`LV_COLOR_FORMAT_NATIVE` but it also adds an alpha (transparency) byte for every pixel.
|
||||||
- :cpp:enumerator:`LV_COLOR_FORMAT_NATIVE_CHROMA_KEYED`: Like :cpp:enumerator:`LV_COLOR_FORMAT_NATIVE` but if a pixel has the
|
- :cpp:enumerator:`LV_COLOR_FORMAT_I1`, :cpp:enumerator:`LV_COLOR_FORMAT_I2`, :cpp:enumerator:`LV_COLOR_FORMAT_I4`, :cpp:enumerator:`LV_COLOR_FORMAT_I8`:
|
||||||
:c:macro:`LV_COLOR_TRANSP` color (set in *lv_conf.h*) it will be transparent.
|
|
||||||
- :cpp:enumerator:`LV_IMG_CF_INDEXED_1BIT`, :cpp:enumerator:`LV_IMG_CF_INDEXED_2BIT`, :cpp:enumerator:`LV_IMG_CF_INDEXED_4BIT`, :cpp:enumerator:`LV_IMG_CF_INDEXED_8BIT`:
|
|
||||||
Uses a palette with 2, 4, 16 or 256 colors and stores each pixel in 1, 2, 4 or 8 bits.
|
Uses a palette with 2, 4, 16 or 256 colors and stores each pixel in 1, 2, 4 or 8 bits.
|
||||||
- :cpp:enumerator:`LV_IMG_CF_ALPHA_1BIT`, :cpp:enumerator:`LV_IMG_CF_ALPHA_2BIT`, :cpp:enumerator:`LV_IMG_CF_ALPHA_4BIT`, :cpp:enumerator:`LV_IMG_CF_ALPHA_8BIT`:
|
- :cpp:enumerator:`LV_COLOR_FORMAT_A1`, :cpp:enumerator:`LV_COLOR_FORMAT_A2`, :cpp:enumerator:`LV_COLOR_FORMAT_A4`, :cpp:enumerator:`LV_COLOR_FORMAT_A8`:
|
||||||
**Only stores the Alpha value with 1, 2, 4 or 8 bits.** The pixels take the color of ``style.img_recolor`` and
|
**Only stores the Alpha value with 1, 2, 4 or 8 bits.** The pixels take the color of ``style.img_recolor`` and
|
||||||
the set opacity. The source image has to be an alpha channel. This is
|
the set opacity. The source image has to be an alpha channel. This is
|
||||||
ideal for bitmaps similar to fonts where the whole image is one color
|
ideal for bitmaps similar to fonts where the whole image is one color
|
||||||
@@ -71,14 +69,14 @@ The bytes of :cpp:enumerator:`LV_COLOR_FORMAT_NATIVE` images are stored in the f
|
|||||||
- **Byte 0**: Blue
|
- **Byte 0**: Blue
|
||||||
- **Byte 1**: Green
|
- **Byte 1**: Green
|
||||||
- **Byte 2**: Red
|
- **Byte 2**: Red
|
||||||
- **Byte 3**: Alpha (only with :cpp:enumerator:`LV_COLOR_FORMAT_NATIVE_ALPHA`)
|
- **Byte 3**: Alpha (only with :cpp:enumerator:`LV_COLOR_FORMAT_NATIVE_WITH_ALPHA`)
|
||||||
- 16-bit color depth:
|
- 16-bit color depth:
|
||||||
- **Byte 0**: Green 3 lower bit, Blue 5 bit
|
- **Byte 0**: Green 3 lower bit, Blue 5 bit
|
||||||
- **Byte 1**: Red 5 bit, Green 3 higher bit
|
- **Byte 1**: Red 5 bit, Green 3 higher bit
|
||||||
- **Byte 2**: Alpha byte (only with :cpp:enumerator:`LV_COLOR_FORMAT_NATIVE_ALPHA`)
|
- **Byte 2**: Alpha byte (only with :cpp:enumerator:`LV_COLOR_FORMAT_NATIVE_WITH_ALPHA`)
|
||||||
- 8-bit color depth:
|
- 8-bit color depth:
|
||||||
- **Byte 0**: Red 3 bit, Green 3 bit, Blue 2 bit
|
- **Byte 0**: Red 3 bit, Green 3 bit, Blue 2 bit
|
||||||
- **Byte 2**: Alpha byte (only with :cpp:enumerator:`LV_COLOR_FORMAT_NATIVE_ALPHA`)
|
- **Byte 2**: Alpha byte (only with :cpp:enumerator:`LV_COLOR_FORMAT_NATIVE_WITH_ALPHA`)
|
||||||
|
|
||||||
You can store images in a *Raw* format to indicate that it's not encoded
|
You can store images in a *Raw* format to indicate that it's not encoded
|
||||||
with one of the built-in color formats and an external `Image decoder <#image-decoder>`__
|
with one of the built-in color formats and an external `Image decoder <#image-decoder>`__
|
||||||
@@ -86,7 +84,6 @@ needs to be used to decode the image.
|
|||||||
|
|
||||||
- :cpp:enumerator:`LV_COLOR_FORMAT_RAW`: Indicates a basic raw image (e.g. a PNG or JPG image).
|
- :cpp:enumerator:`LV_COLOR_FORMAT_RAW`: Indicates a basic raw image (e.g. a PNG or JPG image).
|
||||||
- :cpp:enumerator:`LV_COLOR_FORMAT_RAW_ALPHA`: Indicates that an image has alpha and an alpha byte is added for every pixel.
|
- :cpp:enumerator:`LV_COLOR_FORMAT_RAW_ALPHA`: Indicates that an image has alpha and an alpha byte is added for every pixel.
|
||||||
- :cpp:enumerator:`LV_IMG_CF_RAW_CHROMA_KEYED`: Indicates that an image is chroma-keyed as described in :cpp:enumerator:`LV_COLOR_FORMAT_NATIVE_CHROMA_KEYED` above.
|
|
||||||
|
|
||||||
Add and use images
|
Add and use images
|
||||||
******************
|
******************
|
||||||
@@ -145,9 +142,6 @@ variable to display it using LVGL. For example:
|
|||||||
.data = my_img_data,
|
.data = my_img_data,
|
||||||
};
|
};
|
||||||
|
|
||||||
If the color format is :cpp:enumerator:`LV_COLOR_FORMAT_NATIVE_WITH_ALPHA` you can set
|
|
||||||
``data_size`` like ``80 * 60 *`` :cpp:enumerator:`LV_IMG_PX_SIZE_ALPHA_BYTE`.
|
|
||||||
|
|
||||||
Another (possibly simpler) option to create and display an image at
|
Another (possibly simpler) option to create and display an image at
|
||||||
run-time is to use the `Canvas </widgets/canvas>`__ object.
|
run-time is to use the `Canvas </widgets/canvas>`__ object.
|
||||||
|
|
||||||
@@ -155,7 +149,7 @@ Use images
|
|||||||
----------
|
----------
|
||||||
|
|
||||||
The simplest way to use an image in LVGL is to display it with an
|
The simplest way to use an image in LVGL is to display it with an
|
||||||
`lv_img </widgets/img>`__ object:
|
`lv_image </widgets/img>`__ object:
|
||||||
|
|
||||||
.. code:: c
|
.. code:: c
|
||||||
|
|
||||||
@@ -188,48 +182,43 @@ An image decoder consists of 4 callbacks:
|
|||||||
- **open** open an image:
|
- **open** open an image:
|
||||||
- store a decoded image
|
- store a decoded image
|
||||||
- set it to ``NULL`` to indicate the image can be read line-by-line.
|
- set it to ``NULL`` to indicate the image can be read line-by-line.
|
||||||
- **read** if *open* didn't fully open an image this function should give some decoded data (max 1 line) from a given position.
|
- **get_area** if *open* didn't fully open an image this function should give back part of image as decoded data.
|
||||||
- **close** close an opened image, free the allocated resources.
|
- **close** close an opened image, free the allocated resources.
|
||||||
|
|
||||||
You can add any number of image decoders. When an image needs to be
|
You can add any number of image decoders. When an image needs to be
|
||||||
drawn, the library will try all the registered image decoders until it
|
drawn, the library will try all the registered image decoders until it
|
||||||
finds one which can open the image, i.e. one which knows that format.
|
finds one which can open the image, i.e. one which knows that format.
|
||||||
|
|
||||||
The ``LV_IMG_CF_TRUE_COLOR_...``, ``LV_IMG_INDEXED_...`` and
|
The following formats are understood by the built-in decoder:
|
||||||
``LV_IMG_ALPHA_...`` formats (essentially, all non-``RAW`` formats) are
|
- ``LV_COLOR_FORMAT_I1``
|
||||||
understood by the built-in decoder.
|
- ``LV_COLOR_FORMAT_I2``
|
||||||
|
- ``LV_COLOR_FORMAT_I4``
|
||||||
|
- ``LV_COLOR_FORMAT_I8``
|
||||||
|
- ``LV_COLOR_FORMAT_RGB888``
|
||||||
|
- ``LV_COLOR_FORMAT_XRGB8888``
|
||||||
|
- ``LV_COLOR_FORMAT_ARGB8888``
|
||||||
|
- ``LV_COLOR_FORMAT_RGB565``
|
||||||
|
- ``LV_COLOR_FORMAT_RGB565A8``
|
||||||
|
|
||||||
|
|
||||||
Custom image formats
|
Custom image formats
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
The easiest way to create a custom image is to use the online image
|
The easiest way to create a custom image is to use the online image
|
||||||
converter and select ``Raw``, ``Raw with alpha`` or
|
converter and select ``Raw`` or ``Raw with alpha`` format.
|
||||||
``Raw with chroma-keyed`` format. It will just take every byte of the
|
It will just take every byte of the
|
||||||
binary file you uploaded and write it as an image "bitmap". You then
|
binary file you uploaded and write it as an image "bitmap". You then
|
||||||
need to attach an image decoder that will parse that bitmap and generate
|
need to attach an image decoder that will parse that bitmap and generate
|
||||||
the real, renderable bitmap.
|
the real, renderable bitmap.
|
||||||
|
|
||||||
``header.cf`` will be :cpp:enumerator:`LV_IMG_CF_RAW`, :cpp:enumerator:`LV_IMG_CF_RAW_ALPHA` or
|
``header.cf`` will be :cpp:enumerator:`LV_COLOR_FORMAT_RAW`, :cpp:enumerator:`LV_COLOR_FORMAT_RAW_ALPHA`
|
||||||
:cpp:enumerator:`LV_IMG_CF_RAW_CHROMA_KEYED` accordingly. You should choose the
|
accordingly. You should choose the correct format according to your needs:
|
||||||
correct format according to your needs: a fully opaque image, using an
|
a fully opaque image, using an alpha channel.
|
||||||
alpha channel or using a chroma key.
|
|
||||||
|
|
||||||
After decoding, the *raw* formats are considered *True color* by the
|
After decoding, the *raw* formats are considered *True color* by the
|
||||||
library. In other words, the image decoder must decode the *Raw* images
|
library. In other words, the image decoder must decode the *Raw* images
|
||||||
to *True color* according to the format described in the `Color formats <#color-formats>`__ section.
|
to *True color* according to the format described in the `Color formats <#color-formats>`__ section.
|
||||||
|
|
||||||
If you want to create a custom image, you should use
|
|
||||||
``LV_IMG_CF_USER_ENCODED_0..7`` color formats. However, the library can
|
|
||||||
draw images only in *True color* format (or *Raw* but ultimately it will
|
|
||||||
be in *True color* format). The ``LV_IMG_CF_USER_ENCODED_...`` formats
|
|
||||||
are not known by the library and therefore they should be decoded to one
|
|
||||||
of the known formats from the `Color formats <#color-formats>`__
|
|
||||||
section. It's possible to decode an image to a non-true color format
|
|
||||||
first (for example: :cpp:enumerator:`LV_IMG_INDEXED_4BITS`) and then call the built-in
|
|
||||||
decoder functions to convert it to *True color*.
|
|
||||||
|
|
||||||
With *User encoded* formats, the color format in the open function
|
|
||||||
(``dsc->header.cf``) should be changed according to the new format.
|
|
||||||
|
|
||||||
Register an image decoder
|
Register an image decoder
|
||||||
-------------------------
|
-------------------------
|
||||||
@@ -250,72 +239,67 @@ open/close the PNG files. It should look like this:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get info about a PNG image
|
* Get info about a PNG image
|
||||||
* @param decoder pointer to the decoder where this function belongs
|
* @param decoder pointer to the decoder where this function belongs
|
||||||
* @param src can be file name or pointer to a C array
|
* @param src can be file name or pointer to a C array
|
||||||
* @param header store the info here
|
* @param header image information is set in header parameter
|
||||||
* @return LV_RES_OK: no error; LV_RES_INV: can't get the info
|
* @return LV_RESULT_OK: no error; LV_RESULT_INVALID: can't get the info
|
||||||
*/
|
*/
|
||||||
static lv_res_t decoder_info(lv_image_decoder_t * decoder, const void * src, lv_image_header_t * header)
|
static lv_result_t decoder_info(struct _lv_image_decoder_t * decoder, const void * src, lv_image_header_t * header)
|
||||||
{
|
{
|
||||||
/*Check whether the type `src` is known by the decoder*/
|
/*Check whether the type `src` is known by the decoder*/
|
||||||
if(is_png(src) == false) return LV_RES_INV;
|
if(is_png(src) == false) return LV_RESULT_INVALID;
|
||||||
|
|
||||||
/* Read the PNG header and find `width` and `height` */
|
/* Read the PNG header and find `width` and `height` */
|
||||||
...
|
...
|
||||||
|
|
||||||
header->cf = LV_COLOR_FORMAT_RAW_ALPHA;
|
header->cf = LV_COLOR_FORMAT_ARGB8888;
|
||||||
header->w = width;
|
header->w = width;
|
||||||
header->h = height;
|
header->h = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a PNG image and return the decided image
|
* Open a PNG image and decode it into dsc.img_data
|
||||||
* @param decoder pointer to the decoder where this function belongs
|
* @param decoder pointer to the decoder where this function belongs
|
||||||
* @param dsc pointer to a descriptor which describes this decoding session
|
* @param dsc image descriptor
|
||||||
* @return LV_RES_OK: no error; LV_RES_INV: can't get the info
|
* @return LV_RESULT_OK: no error; LV_RESULT_INVALID: can't open the image
|
||||||
*/
|
*/
|
||||||
static lv_res_t decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc)
|
static lv_result_t decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc)
|
||||||
{
|
{
|
||||||
|
(void) decoder; /*Unused*/
|
||||||
|
|
||||||
/*Check whether the type `src` is known by the decoder*/
|
/*Check whether the type `src` is known by the decoder*/
|
||||||
if(is_png(src) == false) return LV_RES_INV;
|
if(is_png(dsc->src) == false) return LV_RESULT_INVALID;
|
||||||
|
|
||||||
/*Decode and store the image. If `dsc->img_data` is `NULL`, the `read_line` function will be called to get the image data line-by-line*/
|
/*Decode and store the image. If `dsc->img_data` is `NULL`, the `read_line` function will be called to get the image data line-by-line*/
|
||||||
dsc->img_data = my_png_decoder(src);
|
dsc->img_data = my_png_decoder(dsc->src);
|
||||||
|
|
||||||
/*Change the color format if required. For PNG usually 'Raw' is fine*/
|
/*Change the color format if required. For PNG usually 'Raw' is fine*/
|
||||||
dsc->header.cf = LV_COLOR_FORMAT_...
|
dsc->header.cf = LV_COLOR_FORMAT_...
|
||||||
|
|
||||||
/*Call a built in decoder function if required. It's not required if`my_png_decoder` opened the image in true color format.*/
|
/*Call a built in decoder function if required. It's not required if `my_png_decoder` opened the image in true color format.*/
|
||||||
lv_res_t res = lv_image_decoder_built_in_open(decoder, dsc);
|
lv_result_t res = lv_image_decoder_built_in_open(decoder, dsc);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode `len` pixels starting from the given `x`, `y` coordinates and store them in `buf`.
|
* Decode an area of image
|
||||||
* Required only if the "open" function can't open the whole decoded pixel array. (dsc->img_data == NULL)
|
* @param decoder pointer to the decoder where this function belongs
|
||||||
* @param decoder pointer to the decoder the function associated with
|
* @param dsc image decoder descriptor
|
||||||
* @param dsc pointer to decoder descriptor
|
* @param full_area full image area information
|
||||||
* @param x start x coordinate
|
* @param decoded_area area information to decode (x1, y1, x2, y2)
|
||||||
* @param y start y coordinate
|
* @return LV_RESULT_OK: no error; LV_RESULT_INVALID: can't decode image area
|
||||||
* @param len number of pixels to decode
|
|
||||||
* @param buf a buffer to store the decoded pixels
|
|
||||||
* @return LV_RES_OK: ok; LV_RES_INV: failed
|
|
||||||
*/
|
*/
|
||||||
lv_res_t decoder_built_in_read_line(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc, lv_coord_t x,
|
static lv_result_t decoder_get_area(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc,
|
||||||
lv_coord_t y, lv_coord_t len, uint8_t * buf)
|
const lv_area_t * full_area, lv_area_t * decoded_area)
|
||||||
{
|
{
|
||||||
/*With PNG it's usually not required*/
|
|
||||||
|
|
||||||
/*Copy `len` pixels from `x` and `y` coordinates in True color format to `buf` */
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free the allocated resources
|
* Close PNG image and free data
|
||||||
* @param decoder pointer to the decoder where this function belongs
|
* @param decoder pointer to the decoder where this function belongs
|
||||||
* @param dsc pointer to a descriptor which describes this decoding session
|
* @param dsc image decoder descriptor
|
||||||
|
* @return LV_RESULT_OK: no error; LV_RESULT_INVALID: can't open the image
|
||||||
*/
|
*/
|
||||||
static void decoder_close(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc)
|
static void decoder_close(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc)
|
||||||
{
|
{
|
||||||
@@ -331,38 +315,37 @@ So in summary:
|
|||||||
- In ``decoder_info``, you should collect some basic information about the image and store it in ``header``.
|
- In ``decoder_info``, you should collect some basic information about the image and store it in ``header``.
|
||||||
- In ``decoder_open``, you should try to open the image source pointed by
|
- In ``decoder_open``, you should try to open the image source pointed by
|
||||||
``dsc->src``. Its type is already in ``dsc->src_type == LV_IMG_SRC_FILE/VARIABLE``.
|
``dsc->src``. Its type is already in ``dsc->src_type == LV_IMG_SRC_FILE/VARIABLE``.
|
||||||
If this format/type is not supported by the decoder, return :cpp:enumerator:`LV_RES_INV`.
|
If this format/type is not supported by the decoder, return :cpp:enumerator:`LV_RESULT_INVALID`.
|
||||||
However, if you can open the image, a pointer to the decoded *True color* image should be
|
However, if you can open the image, a pointer to the decoded *True color* image should be
|
||||||
set in ``dsc->img_data``. If the format is known, but you don't want to
|
set in ``dsc->img_data``. If the format is known, but you don't want to
|
||||||
decode the entire image (e.g. no memory for it), set ``dsc->img_data = NULL`` and
|
decode the entire image (e.g. no memory for it), set ``dsc->img_data = NULL`` and
|
||||||
use ``read_line`` to get the pixel data.
|
use ``decoder_get_area`` to get the image area pixels.
|
||||||
- In ``decoder_close`` you should free all allocated resources.
|
- In ``decoder_close`` you should free all allocated resources.
|
||||||
- ``decoder_read`` is optional. Decoding the whole image requires extra
|
- ``decoder_get_area`` is optional. In this case you should decode the whole image In
|
||||||
memory and some computational overhead. However, it can decode one line
|
``decoder_open`` function and store image data in ``dsc->img_data``.
|
||||||
of the image without decoding the whole image, you can save memory and
|
Decoding the whole image requires extra memory and some computational overhead.
|
||||||
time. To indicate that the *line read* function should be used, set
|
|
||||||
``dsc->img_data = NULL`` in the open function.
|
|
||||||
|
|
||||||
Manually use an image decoder
|
Manually use an image decoder
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
||||||
LVGL will use registered image decoders automatically if you try and
|
LVGL will use registered image decoders automatically if you try and
|
||||||
draw a raw image (i.e. using the ``lv_img`` object) but you can use them
|
draw a raw image (i.e. using the ``lv_image`` object) but you can use them
|
||||||
manually too. Create an :cpp:type:`lv_image_decoder_dsc_t` variable to describe
|
manually too. Create an :cpp:type:`lv_image_decoder_dsc_t` variable to describe
|
||||||
the decoding session and call :cpp:func:`lv_image_decoder_open`.
|
the decoding session and call :cpp:func:`lv_image_decoder_open`.
|
||||||
|
|
||||||
The ``color`` parameter is used only with ``LV_IMG_CF_ALPHA_1/2/4/8BIT``
|
The ``color`` parameter is used only with ``LV_COLOR_FORMAT_A1/2/4/8``
|
||||||
images to tell color of the image. ``frame_id`` can be used if the image
|
images to tell color of the image. ``frame_id`` can be used if the image
|
||||||
to open is an animation.
|
to open is an animation.
|
||||||
|
|
||||||
.. code:: c
|
.. code:: c
|
||||||
|
|
||||||
|
|
||||||
lv_res_t res;
|
lv_result_t res;
|
||||||
lv_image_decoder_dsc_t dsc;
|
lv_image_decoder_dsc_t dsc;
|
||||||
res = lv_image_decoder_open(&dsc, &my_img_dsc, color, frame_id);
|
res = lv_image_decoder_open(&dsc, &my_img_dsc, color, frame_id);
|
||||||
|
|
||||||
if(res == LV_RES_OK) {
|
if(res == LV_RESULT_OK) {
|
||||||
/*Do something with `dsc->img_data`*/
|
/*Do something with `dsc->img_data`*/
|
||||||
lv_image_decoder_close(&dsc);
|
lv_image_decoder_close(&dsc);
|
||||||
}
|
}
|
||||||
@@ -373,10 +356,10 @@ Image caching
|
|||||||
*************
|
*************
|
||||||
|
|
||||||
Sometimes it takes a lot of time to open an image. Continuously decoding
|
Sometimes it takes a lot of time to open an image. Continuously decoding
|
||||||
a PNG image or loading images from a slow external memory would be
|
a PNG/JPEG image or loading images from a slow external memory would be
|
||||||
inefficient and detrimental to the user experience.
|
inefficient and detrimental to the user experience.
|
||||||
|
|
||||||
Therefore, LVGL caches a given number of images. Caching means some
|
Therefore, LVGL caches image data. Caching means some
|
||||||
images will be left open, hence LVGL can quickly access them from
|
images will be left open, hence LVGL can quickly access them from
|
||||||
``dsc->img_data`` instead of needing to decode them again.
|
``dsc->img_data`` instead of needing to decode them again.
|
||||||
|
|
||||||
@@ -401,7 +384,7 @@ and get with :cpp:expr:`lv_cache_get_max_size()`.
|
|||||||
Value of images
|
Value of images
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
When you use more images than cache entries, LVGL can't cache all the
|
When you use more images than available cache size, LVGL can't cache all the
|
||||||
images. Instead, the library will close one of the cached images to free
|
images. Instead, the library will close one of the cached images to free
|
||||||
space.
|
space.
|
||||||
|
|
||||||
@@ -411,17 +394,18 @@ slower-to-open images are considered more valuable and are kept in the
|
|||||||
cache as long as possible.
|
cache as long as possible.
|
||||||
|
|
||||||
If you want or need to override LVGL's measurement, you can manually set
|
If you want or need to override LVGL's measurement, you can manually set
|
||||||
the *time to open* value in the decoder open function in
|
the *weight* value in the cache entry in
|
||||||
``dsc->time_to_open = time_ms`` to give a higher or lower value. (Leave
|
``cache_entry->weight = time_ms`` to give a higher or lower value. (Leave
|
||||||
it unchanged to let LVGL control it.)
|
it unchanged to let LVGL control it.)
|
||||||
|
|
||||||
Every cache entry has a *"life"* value. Every time an image is opened
|
Every cache entry has a *"life"* value. Every time an image is opened
|
||||||
through the cache, the *life* value of all entries is decreased to make
|
through the cache, the *life* value of all entries is increased by their
|
||||||
them older. When a cached image is used, its *life* value is increased
|
*weight* values to make them older.
|
||||||
by the *time to open* value to make it more alive.
|
When a cached image is used, its *usage_count* value is increased
|
||||||
|
to make it more alive.
|
||||||
|
|
||||||
If there is no more space in the cache, the entry with the lowest life
|
If there is no more space in the cache, the entry with *usage_count == 0*
|
||||||
value will be closed.
|
and lowest life value will be dropped.
|
||||||
|
|
||||||
Memory usage
|
Memory usage
|
||||||
------------
|
------------
|
||||||
@@ -502,7 +486,7 @@ following code to replace the LVGL built-in cache manager:
|
|||||||
|
|
||||||
/*Replace existing cache manager with the new one.*/
|
/*Replace existing cache manager with the new one.*/
|
||||||
lv_cache_lock();
|
lv_cache_lock();
|
||||||
lv_cache_replace_manager(&my_manager);
|
lv_cache_set_manager(&my_manager);
|
||||||
lv_cache_unlock();
|
lv_cache_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ Pointer input devices (like a mouse) can have a cursor.
|
|||||||
lv_indev_t * mouse_indev = lv_indev_create();
|
lv_indev_t * mouse_indev = lv_indev_create();
|
||||||
...
|
...
|
||||||
LV_IMG_DECLARE(mouse_cursor_icon); /*Declare the image source.*/
|
LV_IMG_DECLARE(mouse_cursor_icon); /*Declare the image source.*/
|
||||||
lv_obj_t * cursor_obj = lv_img_create(lv_scr_act()); /*Create an image object for the cursor */
|
lv_obj_t * cursor_obj = lv_image_create(lv_scr_act()); /*Create an image object for the cursor */
|
||||||
lv_img_set_src(cursor_obj, &mouse_cursor_icon); /*Set the image source*/
|
lv_image_set_src(cursor_obj, &mouse_cursor_icon); /*Set the image source*/
|
||||||
lv_indev_set_cursor(mouse_indev, cursor_obj); /*Connect the image object to the driver*/
|
lv_indev_set_cursor(mouse_indev, cursor_obj); /*Connect the image object to the driver*/
|
||||||
|
|
||||||
Note that the cursor object should have
|
Note that the cursor object should have
|
||||||
|
|||||||
@@ -1960,7 +1960,7 @@ Ext. draw No
|
|||||||
bg_img_src
|
bg_img_src
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
|
|
||||||
Set a background image. Can be a pointer to :cpp:struct:`lv_img_dsc_t`, a path to
|
Set a background image. Can be a pointer to :cpp:struct:`lv_image_dsc_t`, a path to
|
||||||
a file or an ``LV_SYMBOL_...``
|
a file or an ``LV_SYMBOL_...``
|
||||||
|
|
||||||
.. raw:: html
|
.. raw:: html
|
||||||
@@ -3782,7 +3782,7 @@ arc_img_src
|
|||||||
|
|
||||||
Set an image from which the arc will be masked out. It's useful to
|
Set an image from which the arc will be masked out. It's useful to
|
||||||
display complex effects on the arcs. Can be a pointer to
|
display complex effects on the arcs. Can be a pointer to
|
||||||
:cpp:struct:`lv_img_dsc_t` or a path to a file
|
:cpp:struct:`lv_image_dsc_t` or a path to a file
|
||||||
|
|
||||||
.. raw:: html
|
.. raw:: html
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -41,13 +41,13 @@ Here is some pseudocode to illustrate the concept:
|
|||||||
{
|
{
|
||||||
/* You must always hold the mutex while using LVGL APIs */
|
/* You must always hold the mutex while using LVGL APIs */
|
||||||
mutex_lock(&lvgl_mutex);
|
mutex_lock(&lvgl_mutex);
|
||||||
lv_obj_t *img = lv_img_create(lv_scr_act());
|
lv_obj_t *img = lv_image_create(lv_scr_act());
|
||||||
mutex_unlock(&lvgl_mutex);
|
mutex_unlock(&lvgl_mutex);
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
mutex_lock(&lvgl_mutex);
|
mutex_lock(&lvgl_mutex);
|
||||||
/* change to the next image */
|
/* change to the next image */
|
||||||
lv_img_set_src(img, next_image);
|
lv_image_set_src(img, next_image);
|
||||||
mutex_unlock(&lvgl_mutex);
|
mutex_unlock(&lvgl_mutex);
|
||||||
thread_sleep(2000);
|
thread_sleep(2000);
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-15
@@ -29,10 +29,10 @@ To provide maximum flexibility, the source of the image can be:
|
|||||||
- a file stored externally (e.g. on an SD card).
|
- a file stored externally (e.g. on an SD card).
|
||||||
- a text with `Symbols </overview/font>`__.
|
- a text with `Symbols </overview/font>`__.
|
||||||
|
|
||||||
To set the source of an image, use :cpp:expr:`lv_img_set_src(img, src)`.
|
To set the source of an image, use :cpp:expr:`lv_image_set_src(img, src)`.
|
||||||
|
|
||||||
To generate a pixel array from a PNG, JPG or BMP image, use the `Online image converter tool <https://lvgl.io/tools/imageconverter>`__
|
To generate a pixel array from a PNG, JPG or BMP image, use the `Online image converter tool <https://lvgl.io/tools/imageconverter>`__
|
||||||
and set the converted image with its pointer :cpp:expr:`lv_img_set_src(img1, &converted_img_var)`
|
and set the converted image with its pointer :cpp:expr:`lv_image_set_src(img1, &converted_img_var)`
|
||||||
To make the variable visible in the C file, you need to declare it with
|
To make the variable visible in the C file, you need to declare it with
|
||||||
:cpp:expr:`LV_IMG_DECLARE(converted_img_var)`.
|
:cpp:expr:`LV_IMG_DECLARE(converted_img_var)`.
|
||||||
|
|
||||||
@@ -41,13 +41,13 @@ the online converter tool but now you should select the binary output
|
|||||||
format. You also need to use LVGL's file system module and register a
|
format. You also need to use LVGL's file system module and register a
|
||||||
driver with some functions for the basic file operation. Go to the
|
driver with some functions for the basic file operation. Go to the
|
||||||
`File system </overview/file-system>`__ to learn more. To set an image sourced
|
`File system </overview/file-system>`__ to learn more. To set an image sourced
|
||||||
from a file, use :cpp:expr:`lv_img_set_src(img, "S:folder1/my_img.bin")`.
|
from a file, use :cpp:expr:`lv_image_set_src(img, "S:folder1/my_img.bin")`.
|
||||||
|
|
||||||
You can also set a symbol similarly to `Labels </widgets/label>`__. In
|
You can also set a symbol similarly to `Labels </widgets/label>`__. In
|
||||||
this case, the image will be rendered as text according to the *font*
|
this case, the image will be rendered as text according to the *font*
|
||||||
specified in the style. It enables to use of light-weight monochrome
|
specified in the style. It enables to use of light-weight monochrome
|
||||||
"letters" instead of real images. You can set symbol like
|
"letters" instead of real images. You can set symbol like
|
||||||
:cpp:expr:`lv_img_set_src(img1, LV_SYMBOL_OK)`.
|
:cpp:expr:`lv_image_set_src(img1, LV_SYMBOL_OK)`.
|
||||||
|
|
||||||
Label as an image
|
Label as an image
|
||||||
-----------------
|
-----------------
|
||||||
@@ -56,7 +56,7 @@ Images and labels are sometimes used to convey the same thing. For
|
|||||||
example, to describe what a button does. Therefore, images and labels
|
example, to describe what a button does. Therefore, images and labels
|
||||||
are somewhat interchangeable, that is the images can display texts by
|
are somewhat interchangeable, that is the images can display texts by
|
||||||
using :c:macro:`LV_SYMBOL_DUMMY` as the prefix of the text. For example,
|
using :c:macro:`LV_SYMBOL_DUMMY` as the prefix of the text. For example,
|
||||||
:cpp:expr:`lv_img_set_src(img, LV_SYMBOL_DUMMY, "Some text")`.
|
:cpp:expr:`lv_image_set_src(img, LV_SYMBOL_DUMMY, "Some text")`.
|
||||||
|
|
||||||
Transparency
|
Transparency
|
||||||
------------
|
------------
|
||||||
@@ -64,8 +64,6 @@ Transparency
|
|||||||
The internal (variable) and external images support 2 transparency
|
The internal (variable) and external images support 2 transparency
|
||||||
handling methods:
|
handling methods:
|
||||||
|
|
||||||
- **Chroma-keying** - Pixels with :c:macro:`LV_COLOR_CHROMA_KEY` (*lv_conf.h*)
|
|
||||||
color will be transparent.
|
|
||||||
- **Alpha byte** - An alpha byte is added to every pixel that contains
|
- **Alpha byte** - An alpha byte is added to every pixel that contains
|
||||||
the pixel's opacity
|
the pixel's opacity
|
||||||
|
|
||||||
@@ -113,8 +111,8 @@ the mosaic feature.
|
|||||||
Offset
|
Offset
|
||||||
------
|
------
|
||||||
|
|
||||||
With :cpp:expr:`lv_img_set_offset_x(img, x_ofs)` and
|
With :cpp:expr:`lv_image_set_offset_x(img, x_ofs)` and
|
||||||
:cpp:expr:`lv_img_set_offset_y(img, y_ofs)`, you can add some offset to the
|
:cpp:expr:`lv_image_set_offset_y(img, y_ofs)`, you can add some offset to the
|
||||||
displayed image. Useful if the object size is smaller than the image
|
displayed image. Useful if the object size is smaller than the image
|
||||||
source size. Using the offset parameter a `Texture atlas <https://en.wikipedia.org/wiki/Texture_atlas>`__
|
source size. Using the offset parameter a `Texture atlas <https://en.wikipedia.org/wiki/Texture_atlas>`__
|
||||||
or a "running image" effect can be created by `Animating </overview/animation>`__ the x or y offset.
|
or a "running image" effect can be created by `Animating </overview/animation>`__ the x or y offset.
|
||||||
@@ -122,24 +120,24 @@ or a "running image" effect can be created by `Animating </overview/animation>`_
|
|||||||
Transformations
|
Transformations
|
||||||
***************
|
***************
|
||||||
|
|
||||||
Using the :cpp:expr:`lv_img_set_zoom(img, factor)` the images will be zoomed.
|
Using the :cpp:expr:`lv_image_set_scale(img, factor)` the images will be zoomed.
|
||||||
Set ``factor`` to ``256`` or :c:macro:`LV_ZOOM_NONE` to disable zooming. A
|
Set ``factor`` to ``256`` or :c:macro:`LV_ZOOM_NONE` to disable zooming. A
|
||||||
larger value enlarges the images (e.g. ``512`` double size), a smaller
|
larger value enlarges the images (e.g. ``512`` double size), a smaller
|
||||||
value shrinks it (e.g. ``128`` half size). Fractional scale works as
|
value shrinks it (e.g. ``128`` half size). Fractional scale works as
|
||||||
well. E.g. ``281`` for 10% enlargement.
|
well. E.g. ``281`` for 10% enlargement.
|
||||||
|
|
||||||
To rotate the image use :cpp:expr:`lv_img_set_angle(img, angle)`. Angle has 0.1
|
To rotate the image use :cpp:expr:`lv_image_set_rotation(img, angle)`. Angle has 0.1
|
||||||
degree precision, so for 45.8° set 458.
|
degree precision, so for 45.8° set 458.
|
||||||
|
|
||||||
The ``transform_zoom`` and ``transform_angle`` style properties are also
|
The ``transform_zoom`` and ``transform_angle`` style properties are also
|
||||||
used to determine the final zoom and angle.
|
used to determine the final zoom and angle.
|
||||||
|
|
||||||
By default, the pivot point of the rotation is the center of the image.
|
By default, the pivot point of the rotation is the center of the image.
|
||||||
It can be changed with :cpp:expr:`lv_img_set_pivot(img, pivot_x, pivot_y)`.
|
It can be changed with :cpp:expr:`lv_image_set_pivot(img, pivot_x, pivot_y)`.
|
||||||
``0;0`` is the top left corner.
|
``0;0`` is the top left corner.
|
||||||
|
|
||||||
The quality of the transformation can be adjusted with
|
The quality of the transformation can be adjusted with
|
||||||
:cpp:expr:`lv_img_set_antialias(img, true)`. With enabled anti-aliasing
|
:cpp:expr:`lv_image_set_antialias(img, true)`. With enabled anti-aliasing
|
||||||
the transformations are higher quality but slower.
|
the transformations are higher quality but slower.
|
||||||
|
|
||||||
The transformations require the whole image to be available. Therefore
|
The transformations require the whole image to be available. Therefore
|
||||||
@@ -170,8 +168,8 @@ the object's boundaries. It also means the layouts are not affected the
|
|||||||
by the transformations.
|
by the transformations.
|
||||||
|
|
||||||
If you need the object size to be updated to the transformed size set
|
If you need the object size to be updated to the transformed size set
|
||||||
:cpp:expr:`lv_img_set_size_mode(img, LV_IMG_SIZE_MODE_REAL)`. (The previous mode
|
:cpp:expr:`lv_image_set_size_mode(img, LV_IMAGE_SIZE_MODE_REAL)`. (The previous mode
|
||||||
is the default and called :cpp:enumerator:`LV_IMG_SIZE_MODE_VIRTUAL`). In this case if
|
is the default and called :cpp:enumerator:`LV_IMAGE_SIZE_MODE_VIRTUAL`). In this case if
|
||||||
the width/height of the object is set to :c:macro:`LV_SIZE_CONTENT` the
|
the width/height of the object is set to :c:macro:`LV_SIZE_CONTENT` the
|
||||||
object's size will be set to the zoomed and rotated size. If an explicit
|
object's size will be set to the zoomed and rotated size. If an explicit
|
||||||
size is set then the overflowing content will be cropped.
|
size is set then the overflowing content will be cropped.
|
||||||
|
|||||||
@@ -36,4 +36,4 @@ void lv_example_rlottie_2(void);
|
|||||||
} /*extern "C"*/
|
} /*extern "C"*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*LV_EXAMPLE_SJPG_H*/
|
#endif /*LV_EXAMPLE_RLOTTIE_H*/
|
||||||
|
|||||||
+4
-4
@@ -31,9 +31,10 @@
|
|||||||
*=========================*/
|
*=========================*/
|
||||||
|
|
||||||
/* Possible values
|
/* Possible values
|
||||||
* - LV_STDLIB_BUILTIN: LVGL's built in implementation
|
* - LV_STDLIB_BUILTIN: LVGL's built in implementation
|
||||||
* - LV_STDLIB_CLIB: Standard C functions, like malloc, strlen, etc
|
* - LV_STDLIB_CLIB: Standard C functions, like malloc, strlen, etc
|
||||||
* - LV_STDLIB_CUSTOM: Implement the functions externally
|
* - LV_STDLIB_MICROPYTHON: MicroPython implementation
|
||||||
|
* - LV_STDLIB_CUSTOM: Implement the functions externally
|
||||||
*/
|
*/
|
||||||
#define LV_USE_STDLIB_MALLOC LV_STDLIB_BUILTIN
|
#define LV_USE_STDLIB_MALLOC LV_STDLIB_BUILTIN
|
||||||
#define LV_USE_STDLIB_STRING LV_STDLIB_BUILTIN
|
#define LV_USE_STDLIB_STRING LV_STDLIB_BUILTIN
|
||||||
@@ -263,7 +264,6 @@
|
|||||||
* 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */
|
* 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */
|
||||||
#define LV_COLOR_MIX_ROUND_OFS 0
|
#define LV_COLOR_MIX_ROUND_OFS 0
|
||||||
|
|
||||||
|
|
||||||
/* Add 2 x 32 bit variables to each lv_obj_t to speed up getting style properties */
|
/* Add 2 x 32 bit variables to each lv_obj_t to speed up getting style properties */
|
||||||
#define LV_OBJ_STYLE_CACHE 0
|
#define LV_OBJ_STYLE_CACHE 0
|
||||||
|
|
||||||
|
|||||||
@@ -32,10 +32,10 @@ static bool event_is_bubbled(lv_event_t * e);
|
|||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* MACROS
|
||||||
**********************/
|
**********************/
|
||||||
#if LV_LOG_TRACE_EVENT
|
#if LV_USE_LOG && LV_LOG_TRACE_EVENT
|
||||||
#define EVENT_TRACE(...) LV_LOG_TRACE(__VA_ARGS__)
|
#define LV_TRACE_EVENT(...) LV_LOG_TRACE(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define EVENT_TRACE(...)
|
#define LV_TRACE_EVENT(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
@@ -287,7 +287,7 @@ lv_draw_task_t * lv_event_get_draw_task(lv_event_t * e)
|
|||||||
|
|
||||||
static lv_result_t event_send_core(lv_event_t * e)
|
static lv_result_t event_send_core(lv_event_t * e)
|
||||||
{
|
{
|
||||||
EVENT_TRACE("Sending event %d to %p with %p param", e->code, (void *)e->original_target, e->param);
|
LV_TRACE_EVENT("Sending event %d to %p with %p param", e->code, (void *)e->original_target, e->param);
|
||||||
|
|
||||||
/*Call the input device's feedback callback if set*/
|
/*Call the input device's feedback callback if set*/
|
||||||
lv_indev_t * indev_act = lv_indev_get_act();
|
lv_indev_t * indev_act = lv_indev_get_act();
|
||||||
|
|||||||
+7
-8
@@ -51,10 +51,10 @@ static void call_flush_cb(lv_display_t * disp, const lv_area_t * area, uint8_t *
|
|||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* MACROS
|
||||||
**********************/
|
**********************/
|
||||||
#if LV_LOG_TRACE_DISP_REFR
|
#if LV_USE_LOG && LV_LOG_TRACE_DISP_REFR
|
||||||
#define REFR_TRACE(...) LV_LOG_TRACE(__VA_ARGS__)
|
#define LV_TRACE_REFR(...) LV_LOG_TRACE(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define REFR_TRACE(...)
|
#define LV_TRACE_REFR(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
@@ -319,7 +319,7 @@ lv_display_t * _lv_refr_get_disp_refreshing(void)
|
|||||||
void _lv_display_refr_timer(lv_timer_t * tmr)
|
void _lv_display_refr_timer(lv_timer_t * tmr)
|
||||||
{
|
{
|
||||||
LV_PROFILER_BEGIN;
|
LV_PROFILER_BEGIN;
|
||||||
REFR_TRACE("begin");
|
LV_TRACE_REFR("begin");
|
||||||
|
|
||||||
if(tmr) {
|
if(tmr) {
|
||||||
disp_refr = tmr->user_data;
|
disp_refr = tmr->user_data;
|
||||||
@@ -416,7 +416,7 @@ refr_finish:
|
|||||||
|
|
||||||
lv_display_send_event(disp_refr, LV_EVENT_REFR_FINISH, NULL);
|
lv_display_send_event(disp_refr, LV_EVENT_REFR_FINISH, NULL);
|
||||||
|
|
||||||
REFR_TRACE("finished");
|
LV_TRACE_REFR("finished");
|
||||||
LV_PROFILER_END;
|
LV_PROFILER_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -950,9 +950,8 @@ static void draw_buf_flush(lv_display_t * disp)
|
|||||||
static void call_flush_cb(lv_display_t * disp, const lv_area_t * area, uint8_t * px_map)
|
static void call_flush_cb(lv_display_t * disp, const lv_area_t * area, uint8_t * px_map)
|
||||||
{
|
{
|
||||||
LV_PROFILER_BEGIN;
|
LV_PROFILER_BEGIN;
|
||||||
REFR_TRACE("Calling flush_cb on (%d;%d)(%d;%d) area with %p image pointer",
|
LV_TRACE_REFR("Calling flush_cb on (%d;%d)(%d;%d) area with %p image pointer",
|
||||||
(int)area->x1, (int)area->y1, (int)area->x2, (int)area->y2,
|
(int)area->x1, (int)area->y1, (int)area->x2, (int)area->y2, (void *)px_map);
|
||||||
(void *)px_map);
|
|
||||||
|
|
||||||
lv_area_t offset_area = {
|
lv_area_t offset_area = {
|
||||||
.x1 = area->x1 + disp->offset_x,
|
.x1 = area->x1 + disp->offset_x,
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ typedef struct _lv_draw_image_dsc_t {
|
|||||||
lv_coord_t zoom;
|
lv_coord_t zoom;
|
||||||
lv_point_t pivot;
|
lv_point_t pivot;
|
||||||
|
|
||||||
lv_color_t chroma_key_color;
|
|
||||||
lv_color_t recolor;
|
lv_color_t recolor;
|
||||||
lv_opa_t recolor_opa;
|
lv_opa_t recolor_opa;
|
||||||
|
|
||||||
|
|||||||
+11
-12
@@ -171,13 +171,12 @@ lv_result_t lv_image_decoder_open(lv_image_decoder_dsc_t * dsc, const void * src
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read a line from an opened image
|
* Decode an area of image
|
||||||
* @param dsc pointer to `lv_image_decoder_dsc_t` used in `lv_image_decoder_open`
|
* @param decoder pointer to the decoder where this function belongs
|
||||||
* @param x start X coordinate (from left)
|
* @param dsc pointer to `lv_image_decoder_dsc_t` used in `lv_image_decoder_open`
|
||||||
* @param y start Y coordinate (from top)
|
* @param full_area full image area information
|
||||||
* @param len number of pixels to read
|
* @param decoded_area area information to decode (x1, y1, x2, y2)
|
||||||
* @param buf store the data here
|
* @return LV_RESULT_OK: no error; LV_RESULT_INVALID: can't decode image area
|
||||||
* @return LV_RESULT_OK: success; LV_RESULT_INVALID: an error occurred
|
|
||||||
*/
|
*/
|
||||||
lv_result_t lv_image_decoder_get_area(lv_image_decoder_dsc_t * dsc, const lv_area_t * full_area,
|
lv_result_t lv_image_decoder_get_area(lv_image_decoder_dsc_t * dsc, const lv_area_t * full_area,
|
||||||
lv_area_t * decoded_area)
|
lv_area_t * decoded_area)
|
||||||
@@ -264,13 +263,13 @@ void lv_image_decoder_set_open_cb(lv_image_decoder_t * decoder, lv_image_decoder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a callback to a decoded line of an image
|
* Set a callback to get decoded area of an image
|
||||||
* @param decoder pointer to an image decoder
|
* @param decoder pointer to an image decoder
|
||||||
* @param read_line_cb a function to read a line of an image
|
* @param get_area_cb a function to get area of an image
|
||||||
*/
|
*/
|
||||||
void lv_image_decoder_set_get_area_cb(lv_image_decoder_t * decoder, lv_image_decoder_get_area_cb_t read_line_cb)
|
void lv_image_decoder_set_get_area_cb(lv_image_decoder_t * decoder, lv_image_decoder_get_area_cb_t get_area_cb)
|
||||||
{
|
{
|
||||||
decoder->get_area_cb = read_line_cb;
|
decoder->get_area_cb = get_area_cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -173,13 +173,11 @@ lv_result_t lv_image_decoder_get_info(const void * src, lv_image_header_t * head
|
|||||||
lv_result_t lv_image_decoder_open(lv_image_decoder_dsc_t * dsc, const void * src, lv_color_t color, int32_t frame_id);
|
lv_result_t lv_image_decoder_open(lv_image_decoder_dsc_t * dsc, const void * src, lv_color_t color, int32_t frame_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read a line from an opened image
|
* Decode an area of the opened image
|
||||||
* @param dsc pointer to `lv_image_decoder_dsc_t` used in `lv_image_decoder_open`
|
* @param dsc image decoder descriptor
|
||||||
* @param x start X coordinate (from left)
|
* @param full_area start X coordinate (from left)
|
||||||
* @param y start Y coordinate (from top)
|
* @param decoded_area start Y coordinate (from top)
|
||||||
* @param len number of pixels to read
|
* @return LV_RESULT_OK: success; LV_RESULT_INVALID: an error occurred
|
||||||
* @param buf store the data here
|
|
||||||
* @return LV_RESULT_OK: success; LV_RESULT_INVALID: an error occurred
|
|
||||||
*/
|
*/
|
||||||
lv_result_t lv_image_decoder_get_area(lv_image_decoder_dsc_t * dsc, const lv_area_t * full_area,
|
lv_result_t lv_image_decoder_get_area(lv_image_decoder_dsc_t * dsc, const lv_area_t * full_area,
|
||||||
lv_area_t * decoded_area);
|
lv_area_t * decoded_area);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @file lv_draw_arc.c
|
* @file lv_draw_sw_arc.c
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -273,4 +273,4 @@ static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t thickness
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif /*LV_DRAW_SW_COMPLEX*/
|
#endif /*LV_DRAW_SW_COMPLEX*/
|
||||||
#endif /*LV_USE_DRAW_SW_ARC*/
|
#endif /*LV_USE_DRAW_SW*/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @file lv_draw_rect.c
|
* @file lv_draw_sw_bg_img.c
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -112,4 +112,4 @@ void lv_draw_sw_bg_image(lv_draw_unit_t * draw_unit, const lv_draw_bg_image_dsc_
|
|||||||
* STATIC FUNCTIONS
|
* STATIC FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
#endif
|
#endif /*LV_USE_DRAW_SW*/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @file lv_draw_rect.c
|
* @file lv_draw_sw_border.c
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @file lv_draw_rect.c
|
* @file lv_draw_sw_box_shadow.c
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
LV_ATTRIBUTE_FAST_MEM static void shadow_draw_corner_buf(const lv_area_t * coords, uint16_t * sh_buf, lv_coord_t s,
|
LV_ATTRIBUTE_FAST_MEM static void shadow_draw_corner_buf(const lv_area_t * coords, uint16_t * sh_buf, lv_coord_t s,
|
||||||
lv_coord_t r);
|
lv_coord_t r);
|
||||||
LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t sw, uint16_t * sh_ups_buf);
|
LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t sw, uint16_t * sh_ups_buf);
|
||||||
#endif
|
#endif /*LV_DRAW_SW_COMPLEX*/
|
||||||
|
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
@@ -120,7 +120,7 @@ void lv_draw_sw_box_shadow(lv_draw_unit_t * draw_unit, const lv_draw_box_shadow_
|
|||||||
#else
|
#else
|
||||||
sh_buf = lv_malloc(corner_size * corner_size * sizeof(uint16_t));
|
sh_buf = lv_malloc(corner_size * corner_size * sizeof(uint16_t));
|
||||||
shadow_draw_corner_buf(&core_area, (uint16_t *)sh_buf, dsc->width, r_sh);
|
shadow_draw_corner_buf(&core_area, (uint16_t *)sh_buf, dsc->width, r_sh);
|
||||||
#endif
|
#endif /*LV_DRAW_SW_SHADOW_CACHE_SIZE*/
|
||||||
|
|
||||||
/*Skip a lot of masking if the background will cover the shadow that would be masked out*/
|
/*Skip a lot of masking if the background will cover the shadow that would be masked out*/
|
||||||
bool simple = dsc->bg_cover;
|
bool simple = dsc->bg_cover;
|
||||||
@@ -553,7 +553,7 @@ void lv_draw_sw_box_shadow(lv_draw_unit_t * draw_unit, const lv_draw_box_shadow_
|
|||||||
lv_free(sh_buf);
|
lv_free(sh_buf);
|
||||||
lv_free(mask_buf);
|
lv_free(mask_buf);
|
||||||
}
|
}
|
||||||
#endif /*LV_DRAW_MASKS*/
|
#endif /*LV_USE_DRAW_SW*/
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC FUNCTIONS
|
* STATIC FUNCTIONS
|
||||||
@@ -589,7 +589,7 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_draw_corner_buf(const lv_area_t * coord
|
|||||||
/*Set half shadow width width because blur will be repeated*/
|
/*Set half shadow width width because blur will be repeated*/
|
||||||
if(sw_ori == 1) sw = 1;
|
if(sw_ori == 1) sw = 1;
|
||||||
else sw = sw_ori >> 1;
|
else sw = sw_ori >> 1;
|
||||||
#endif
|
#endif /*SHADOW_ENHANCE*/
|
||||||
|
|
||||||
int32_t y;
|
int32_t y;
|
||||||
lv_opa_t * mask_line = lv_malloc(size);
|
lv_opa_t * mask_line = lv_malloc(size);
|
||||||
@@ -727,4 +727,4 @@ LV_ATTRIBUTE_FAST_MEM static void shadow_blur_corner(lv_coord_t size, lv_coord_t
|
|||||||
|
|
||||||
lv_free(sh_ups_blur_buf);
|
lv_free(sh_ups_blur_buf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /*LV_DRAW_SW_COMPLEX*/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @file lv_draw_rect.c
|
* @file lv_draw_sw_fill.c
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -211,4 +211,4 @@ void lv_draw_sw_fill(lv_draw_unit_t * draw_unit, const lv_draw_fill_dsc_t * dsc,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /*LV_USE_DRAW_SW*/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @file lv_draw_img.c
|
* @file lv_draw_sw_img.c
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @file lv_draw_mask.c
|
* @file lv_draw_sw_mask_rect.c
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -80,10 +80,10 @@ static void indev_reset_core(lv_indev_t * indev, lv_obj_t * obj);
|
|||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* MACROS
|
||||||
**********************/
|
**********************/
|
||||||
#if LV_LOG_TRACE_INDEV
|
#if LV_USE_LOG && LV_LOG_TRACE_INDEV
|
||||||
#define INDEV_TRACE(...) LV_LOG_TRACE(__VA_ARGS__)
|
#define LV_TRACE_INDEV(...) LV_LOG_TRACE(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define INDEV_TRACE(...)
|
#define LV_TRACE_INDEV(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
@@ -159,7 +159,7 @@ void indev_read_core(lv_indev_t * indev, lv_indev_data_t * data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(indev->read_cb) {
|
if(indev->read_cb) {
|
||||||
INDEV_TRACE("calling indev_read_cb");
|
LV_TRACE_INDEV("calling indev_read_cb");
|
||||||
indev->read_cb(indev, data);
|
indev->read_cb(indev, data);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -177,7 +177,7 @@ void lv_indev_read(lv_indev_t * indev_p)
|
|||||||
{
|
{
|
||||||
if(!indev_p) return;
|
if(!indev_p) return;
|
||||||
|
|
||||||
INDEV_TRACE("begin");
|
LV_TRACE_INDEV("begin");
|
||||||
|
|
||||||
indev_act = indev_p;
|
indev_act = indev_p;
|
||||||
|
|
||||||
@@ -234,7 +234,7 @@ void lv_indev_read(lv_indev_t * indev_p)
|
|||||||
indev_act = NULL;
|
indev_act = NULL;
|
||||||
indev_obj_act = NULL;
|
indev_obj_act = NULL;
|
||||||
|
|
||||||
INDEV_TRACE("finished");
|
LV_TRACE_INDEV("finished");
|
||||||
LV_PROFILER_END;
|
LV_PROFILER_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ void lv_gif_set_src(lv_obj_t * obj, const void * src)
|
|||||||
/*Close previous gif if any*/
|
/*Close previous gif if any*/
|
||||||
if(gifobj->gif) {
|
if(gifobj->gif) {
|
||||||
lv_cache_lock();
|
lv_cache_lock();
|
||||||
lv_cache_invalidate(lv_cache_find(lv_img_get_src(obj), LV_CACHE_SRC_TYPE_PTR, 0, 0));
|
lv_cache_invalidate(lv_cache_find(lv_image_get_src(obj), LV_CACHE_SRC_TYPE_PTR, 0, 0));
|
||||||
lv_cache_unlock();
|
lv_cache_unlock();
|
||||||
|
|
||||||
gd_close_gif(gifobj->gif);
|
gd_close_gif(gifobj->gif);
|
||||||
@@ -129,7 +129,7 @@ static void lv_gif_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
|||||||
lv_gif_t * gifobj = (lv_gif_t *) obj;
|
lv_gif_t * gifobj = (lv_gif_t *) obj;
|
||||||
|
|
||||||
lv_cache_lock();
|
lv_cache_lock();
|
||||||
lv_cache_invalidate(lv_cache_find(lv_img_get_src(obj), LV_CACHE_SRC_TYPE_PTR, 0, 0));
|
lv_cache_invalidate(lv_cache_find(lv_image_get_src(obj), LV_CACHE_SRC_TYPE_PTR, 0, 0));
|
||||||
lv_cache_unlock();
|
lv_cache_unlock();
|
||||||
|
|
||||||
if(gifobj->gif)
|
if(gifobj->gif)
|
||||||
@@ -157,7 +157,7 @@ static void next_frame_task_cb(lv_timer_t * t)
|
|||||||
gd_render_frame(gifobj->gif, (uint8_t *)gifobj->imgdsc.data);
|
gd_render_frame(gifobj->gif, (uint8_t *)gifobj->imgdsc.data);
|
||||||
|
|
||||||
lv_cache_lock();
|
lv_cache_lock();
|
||||||
lv_cache_invalidate(lv_cache_find(lv_img_get_src(obj), LV_CACHE_SRC_TYPE_PTR, 0, 0));
|
lv_cache_invalidate(lv_cache_find(lv_image_get_src(obj), LV_CACHE_SRC_TYPE_PTR, 0, 0));
|
||||||
lv_cache_unlock();
|
lv_cache_unlock();
|
||||||
lv_obj_invalidate(obj);
|
lv_obj_invalidate(obj);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,9 +71,10 @@ void lv_lodepng_deinit(void)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get info about a PNG image
|
* Get info about a PNG image
|
||||||
* @param src can be file name or pointer to a C array
|
* @param decoder pointer to the decoder where this function belongs
|
||||||
* @param header store the info here
|
* @param src can be file name or pointer to a C array
|
||||||
* @return LV_RESULT_OK: no error; LV_RESULT_INVALID: can't get the info
|
* @param header image information is set in header parameter
|
||||||
|
* @return LV_RESULT_OK: no error; LV_RESULT_INVALID: can't get the info
|
||||||
*/
|
*/
|
||||||
static lv_result_t decoder_info(struct _lv_image_decoder_t * decoder, const void * src, lv_image_header_t * header)
|
static lv_result_t decoder_info(struct _lv_image_decoder_t * decoder, const void * src, lv_image_header_t * header)
|
||||||
{
|
{
|
||||||
@@ -146,14 +147,13 @@ static lv_result_t decoder_info(struct _lv_image_decoder_t * decoder, const void
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a PNG image and return the decided image
|
* Open a PNG image and decode it into dsc.img_data
|
||||||
* @param src can be file name or pointer to a C array
|
* @param decoder pointer to the decoder where this function belongs
|
||||||
* @param style style of the image object (unused now but certain formats might use it)
|
* @param dsc decoded image descriptor
|
||||||
* @return pointer to the decoded image or `LV_IMAGE_DECODER_OPEN_FAIL` if failed
|
* @return LV_RESULT_OK: no error; LV_RESULT_INVALID: can't open the image
|
||||||
*/
|
*/
|
||||||
static lv_result_t decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc)
|
static lv_result_t decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc)
|
||||||
{
|
{
|
||||||
|
|
||||||
(void) decoder; /*Unused*/
|
(void) decoder; /*Unused*/
|
||||||
|
|
||||||
/*Check the cache first*/
|
/*Check the cache first*/
|
||||||
@@ -176,7 +176,7 @@ static lv_result_t decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_d
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(dsc->src_type == LV_IMAGE_SRC_VARIABLE) {
|
else if(dsc->src_type == LV_IMAGE_SRC_VARIABLE) {
|
||||||
const lv_img_dsc_t * img_dsc = dsc->src;
|
const lv_image_dsc_t * img_dsc = dsc->src;
|
||||||
png_data = img_dsc->data;
|
png_data = img_dsc->data;
|
||||||
png_data_size = img_dsc->data_size;
|
png_data_size = img_dsc->data_size;
|
||||||
}
|
}
|
||||||
@@ -215,9 +215,15 @@ static lv_result_t decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_d
|
|||||||
return LV_RESULT_OK; /*If not returned earlier then it failed*/
|
return LV_RESULT_OK; /*If not returned earlier then it failed*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static void decoder_close(lv_image_decoder_t * dec, lv_image_decoder_dsc_t * dsc)
|
/**
|
||||||
|
* Close PNG image and free data
|
||||||
|
* @param decoder pointer to the decoder where this function belongs
|
||||||
|
* @param dsc decoded image descriptor
|
||||||
|
* @return LV_RESULT_OK: no error; LV_RESULT_INVALID: can't open the image
|
||||||
|
*/
|
||||||
|
static void decoder_close(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc)
|
||||||
{
|
{
|
||||||
LV_UNUSED(dec);
|
LV_UNUSED(decoder);
|
||||||
|
|
||||||
lv_cache_lock();
|
lv_cache_lock();
|
||||||
lv_cache_release(dsc->user_data);
|
lv_cache_release(dsc->user_data);
|
||||||
@@ -241,7 +247,7 @@ static lv_result_t try_cache(lv_image_decoder_dsc_t * dsc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if(dsc->src_type == LV_IMAGE_SRC_VARIABLE) {
|
else if(dsc->src_type == LV_IMAGE_SRC_VARIABLE) {
|
||||||
const lv_img_dsc_t * img_dsc = dsc->src;
|
const lv_image_dsc_t * img_dsc = dsc->src;
|
||||||
|
|
||||||
lv_cache_entry_t * cache = lv_cache_find(img_dsc, LV_CACHE_SRC_TYPE_PTR, 0, 0);
|
lv_cache_entry_t * cache = lv_cache_find(img_dsc, LV_CACHE_SRC_TYPE_PTR, 0, 0);
|
||||||
if(cache) {
|
if(cache) {
|
||||||
@@ -274,7 +280,6 @@ static const void * decode_png_data(const void * png_data, size_t png_data_size)
|
|||||||
convert_color_depth(img_data, png_width * png_height);
|
convert_color_depth(img_data, png_width * png_height);
|
||||||
|
|
||||||
return img_data;
|
return img_data;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -233,16 +233,20 @@ static lv_result_t decoder_get_area(lv_image_decoder_t * decoder, lv_image_decod
|
|||||||
decoded_area->y2 += my;
|
decoded_area->y2 += my;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Process restart interval if enabled */
|
||||||
JRESULT rc;
|
JRESULT rc;
|
||||||
if(jd->nrst && jd->rst++ == jd->nrst) { /* Process restart interval if enabled */
|
if(jd->nrst && jd->rst++ == jd->nrst) {
|
||||||
rc = jd_restart(jd, jd->rsc++);
|
rc = jd_restart(jd, jd->rsc++);
|
||||||
if(rc != JDR_OK) return rc;
|
if(rc != JDR_OK) return rc;
|
||||||
jd->rst = 1;
|
jd->rst = 1;
|
||||||
}
|
}
|
||||||
rc = jd_mcu_load(jd); /* Load an MCU (decompress huffman coded stream, dequantize and apply IDCT) */
|
|
||||||
|
/* Load an MCU (decompress huffman coded stream, dequantize and apply IDCT) */
|
||||||
|
rc = jd_mcu_load(jd);
|
||||||
if(rc != JDR_OK) return rc;
|
if(rc != JDR_OK) return rc;
|
||||||
rc = jd_mcu_output(jd, NULL, decoded_area->x1,
|
|
||||||
decoded_area->y1); /* Output the MCU (YCbCr to RGB, scaling and output) */
|
/* Output the MCU (YCbCr to RGB, scaling and output) */
|
||||||
|
rc = jd_mcu_output(jd, NULL, decoded_area->x1, decoded_area->y1);
|
||||||
if(rc != JDR_OK) return rc;
|
if(rc != JDR_OK) return rc;
|
||||||
|
|
||||||
return LV_RESULT_OK;
|
return LV_RESULT_OK;
|
||||||
|
|||||||
@@ -75,9 +75,10 @@
|
|||||||
*=========================*/
|
*=========================*/
|
||||||
|
|
||||||
/* Possible values
|
/* Possible values
|
||||||
* - LV_STDLIB_BUILTIN: LVGL's built in implementation
|
* - LV_STDLIB_BUILTIN: LVGL's built in implementation
|
||||||
* - LV_STDLIB_CLIB: Standard C functions, like malloc, strlen, etc
|
* - LV_STDLIB_CLIB: Standard C functions, like malloc, strlen, etc
|
||||||
* - LV_STDLIB_CUSTOM: Implement the functions externally
|
* - LV_STDLIB_MICROPYTHON: MicroPython implementation
|
||||||
|
* - LV_STDLIB_CUSTOM: Implement the functions externally
|
||||||
*/
|
*/
|
||||||
#ifndef LV_USE_STDLIB_MALLOC
|
#ifndef LV_USE_STDLIB_MALLOC
|
||||||
#ifdef CONFIG_LV_USE_STDLIB_MALLOC
|
#ifdef CONFIG_LV_USE_STDLIB_MALLOC
|
||||||
@@ -729,7 +730,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Add 2 x 32 bit variables to each lv_obj_t to speed up getting style properties */
|
/* Add 2 x 32 bit variables to each lv_obj_t to speed up getting style properties */
|
||||||
#ifndef LV_OBJ_STYLE_CACHE
|
#ifndef LV_OBJ_STYLE_CACHE
|
||||||
#ifdef CONFIG_LV_OBJ_STYLE_CACHE
|
#ifdef CONFIG_LV_OBJ_STYLE_CACHE
|
||||||
|
|||||||
@@ -25,14 +25,6 @@ extern "C" {
|
|||||||
|
|
||||||
#endif /*LV_CONF_KCONFIG_EXTERNAL_INCLUDE*/
|
#endif /*LV_CONF_KCONFIG_EXTERNAL_INCLUDE*/
|
||||||
|
|
||||||
/*******************
|
|
||||||
* LV COLOR CHROMA KEY
|
|
||||||
*******************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_LV_COLOR_CHROMA_KEY_HEX
|
|
||||||
# define CONFIG_LV_COLOR_CHROMA_KEY lv_color_hex(CONFIG_LV_COLOR_CHROMA_KEY_HEX)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*******************
|
/*******************
|
||||||
* LV_USE_STDLIB_MALLOC
|
* LV_USE_STDLIB_MALLOC
|
||||||
*******************/
|
*******************/
|
||||||
|
|||||||
+1
-1
@@ -44,7 +44,7 @@ static int32_t lv_anim_path_cubic_bezier(const lv_anim_t * a, int32_t x1,
|
|||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* MACROS
|
||||||
**********************/
|
**********************/
|
||||||
#if LV_LOG_TRACE_ANIM
|
#if LV_USE_LOG && LV_LOG_TRACE_ANIM
|
||||||
#define LV_TRACE_ANIM(...) LV_LOG_TRACE(__VA_ARGS__)
|
#define LV_TRACE_ANIM(...) LV_LOG_TRACE(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define LV_TRACE_ANIM(...)
|
#define LV_TRACE_ANIM(...)
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ lv_cache_entry_t * lv_cache_find(const void * src_ptr, lv_cache_src_type_t src_t
|
|||||||
return _cache_manager.find_cb(src_ptr, src_type, param1, param2);
|
return _cache_manager.find_cb(src_ptr, src_type, param1, param2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void lv_cache_invalidate(lv_cache_entry_t * entry)
|
void lv_cache_invalidate(lv_cache_entry_t * entry)
|
||||||
{
|
{
|
||||||
LV_ASSERT(_cache_manager.locked);
|
LV_ASSERT(_cache_manager.locked);
|
||||||
|
|||||||
+3
-3
@@ -35,10 +35,10 @@
|
|||||||
* MACROS
|
* MACROS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
#if LV_LOG_TRACE_EVENT
|
#if LV_USE_LOG && LV_LOG_TRACE_EVENT
|
||||||
#define EVENT_TRACE(...) LV_LOG_TRACE(__VA_ARGS__)
|
#define LV_TRACE_EVENT(...) LV_LOG_TRACE(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define EVENT_TRACE(...)
|
#define LV_TRACE_EVENT(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
|
|||||||
@@ -148,7 +148,6 @@ typedef uint8_t lv_grad_dir_t;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The dithering algorithm for the gradient
|
* The dithering algorithm for the gradient
|
||||||
* Depends on LV_DRAW_SW_GRADIENT_DITHER
|
|
||||||
*/
|
*/
|
||||||
enum _lv_dither_mode_t {
|
enum _lv_dither_mode_t {
|
||||||
LV_DITHER_NONE, /**< No dithering, colors are just quantized to the output resolution*/
|
LV_DITHER_NONE, /**< No dithering, colors are just quantized to the output resolution*/
|
||||||
|
|||||||
+12
-12
@@ -42,10 +42,10 @@ static void lv_timer_handler_resume(void);
|
|||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* MACROS
|
||||||
**********************/
|
**********************/
|
||||||
#if LV_LOG_TRACE_TIMER
|
#if LV_USE_LOG && LV_LOG_TRACE_TIMER
|
||||||
#define TIMER_TRACE(...) LV_LOG_TRACE(__VA_ARGS__)
|
#define LV_TRACE_TIMER(...) LV_LOG_TRACE(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define TIMER_TRACE(...)
|
#define LV_TRACE_TIMER(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
@@ -69,12 +69,12 @@ void _lv_timer_core_init(void)
|
|||||||
*/
|
*/
|
||||||
LV_ATTRIBUTE_TIMER_HANDLER uint32_t lv_timer_handler(void)
|
LV_ATTRIBUTE_TIMER_HANDLER uint32_t lv_timer_handler(void)
|
||||||
{
|
{
|
||||||
TIMER_TRACE("begin");
|
LV_TRACE_TIMER("begin");
|
||||||
|
|
||||||
lv_timer_state_t * state_p = &state;
|
lv_timer_state_t * state_p = &state;
|
||||||
/*Avoid concurrent running of the timer handler*/
|
/*Avoid concurrent running of the timer handler*/
|
||||||
if(state_p->already_running) {
|
if(state_p->already_running) {
|
||||||
TIMER_TRACE("already running, concurrent calls are not allow, returning");
|
LV_TRACE_TIMER("already running, concurrent calls are not allow, returning");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
state_p->already_running = true;
|
state_p->already_running = true;
|
||||||
@@ -112,7 +112,7 @@ LV_ATTRIBUTE_TIMER_HANDLER uint32_t lv_timer_handler(void)
|
|||||||
if(lv_timer_exec(timer_active)) {
|
if(lv_timer_exec(timer_active)) {
|
||||||
/*If a timer was created or deleted then this or the next item might be corrupted*/
|
/*If a timer was created or deleted then this or the next item might be corrupted*/
|
||||||
if(state_p->timer_created || state_p->timer_deleted) {
|
if(state_p->timer_created || state_p->timer_deleted) {
|
||||||
TIMER_TRACE("Start from the first timer again because a timer was created or deleted");
|
LV_TRACE_TIMER("Start from the first timer again because a timer was created or deleted");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,7 +145,7 @@ LV_ATTRIBUTE_TIMER_HANDLER uint32_t lv_timer_handler(void)
|
|||||||
state_p->timer_time_until_next = time_until_next;
|
state_p->timer_time_until_next = time_until_next;
|
||||||
state_p->already_running = false; /*Release the mutex*/
|
state_p->already_running = false; /*Release the mutex*/
|
||||||
|
|
||||||
TIMER_TRACE("finished (%" LV_PRIu32 " ms until the next timer call)", time_until_next);
|
LV_TRACE_TIMER("finished (%" LV_PRIu32 " ms until the next timer call)", time_until_next);
|
||||||
LV_PROFILER_END;
|
LV_PROFILER_END;
|
||||||
return time_until_next;
|
return time_until_next;
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ LV_ATTRIBUTE_TIMER_HANDLER void lv_timer_periodic_handler(void)
|
|||||||
{
|
{
|
||||||
lv_timer_state_t * state_p = &state;
|
lv_timer_state_t * state_p = &state;
|
||||||
if(lv_tick_elaps(state_p->periodic_last_tick) >= state_p->timer_time_until_next) {
|
if(lv_tick_elaps(state_p->periodic_last_tick) >= state_p->timer_time_until_next) {
|
||||||
TIMER_TRACE("calling lv_timer_handler()");
|
LV_TRACE_TIMER("calling lv_timer_handler()");
|
||||||
lv_timer_handler();
|
lv_timer_handler();
|
||||||
state_p->periodic_last_tick = lv_tick_get();
|
state_p->periodic_last_tick = lv_tick_get();
|
||||||
}
|
}
|
||||||
@@ -348,15 +348,15 @@ static bool lv_timer_exec(lv_timer_t * timer)
|
|||||||
int32_t original_repeat_count = timer->repeat_count;
|
int32_t original_repeat_count = timer->repeat_count;
|
||||||
if(timer->repeat_count > 0) timer->repeat_count--;
|
if(timer->repeat_count > 0) timer->repeat_count--;
|
||||||
timer->last_run = lv_tick_get();
|
timer->last_run = lv_tick_get();
|
||||||
TIMER_TRACE("calling timer callback: %p", *((void **)&timer->timer_cb));
|
LV_TRACE_TIMER("calling timer callback: %p", *((void **)&timer->timer_cb));
|
||||||
|
|
||||||
if(timer->timer_cb && original_repeat_count != 0) timer->timer_cb(timer);
|
if(timer->timer_cb && original_repeat_count != 0) timer->timer_cb(timer);
|
||||||
|
|
||||||
if(!state.timer_deleted) {
|
if(!state.timer_deleted) {
|
||||||
TIMER_TRACE("timer callback %p finished", *((void **)&timer->timer_cb));
|
LV_TRACE_TIMER("timer callback %p finished", *((void **)&timer->timer_cb));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
TIMER_TRACE("timer callback finished");
|
LV_TRACE_TIMER("timer callback finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
LV_ASSERT_MEM_INTEGRITY();
|
LV_ASSERT_MEM_INTEGRITY();
|
||||||
@@ -365,7 +365,7 @@ static bool lv_timer_exec(lv_timer_t * timer)
|
|||||||
|
|
||||||
if(state.timer_deleted == false) { /*The timer might be deleted by itself as well*/
|
if(state.timer_deleted == false) { /*The timer might be deleted by itself as well*/
|
||||||
if(timer->repeat_count == 0) { /*The repeat count is over, delete the timer*/
|
if(timer->repeat_count == 0) { /*The repeat count is over, delete the timer*/
|
||||||
TIMER_TRACE("deleting timer with %p callback because the repeat count is over", *((void **)&timer->timer_cb));
|
LV_TRACE_TIMER("deleting timer with %p callback because the repeat count is over", *((void **)&timer->timer_cb));
|
||||||
lv_timer_del(timer);
|
lv_timer_del(timer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ static void obj_delete_event_cb(lv_event_t * e);
|
|||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* MACROS
|
||||||
**********************/
|
**********************/
|
||||||
#if LV_LOG_TRACE_MSG
|
#if LV_USE_LOG && LV_LOG_TRACE_MSG
|
||||||
#define LV_TRACE_MSG(...) LV_LOG_TRACE(__VA_ARGS__)
|
#define LV_TRACE_MSG(...) LV_LOG_TRACE(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define LV_TRACE_MSG(...)
|
#define LV_TRACE_MSG(...)
|
||||||
|
|||||||
@@ -39,12 +39,11 @@
|
|||||||
* GLOBAL FUNCTIONS
|
* GLOBAL FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
/** Get the buffer needed for object snapshot image.
|
/**
|
||||||
*
|
* Get the buffer needed for object snapshot image.
|
||||||
* @param obj The object to generate snapshot.
|
* @param obj the object to generate snapshot.
|
||||||
* @param cf color format for generated image.
|
* @param cf color format for generated image.
|
||||||
*
|
* @return the buffer size needed in bytes
|
||||||
* @return the buffer size needed in bytes
|
|
||||||
*/
|
*/
|
||||||
uint32_t lv_snapshot_buf_size_needed(lv_obj_t * obj, lv_color_format_t cf)
|
uint32_t lv_snapshot_buf_size_needed(lv_obj_t * obj, lv_color_format_t cf)
|
||||||
{
|
{
|
||||||
@@ -72,15 +71,14 @@ uint32_t lv_snapshot_buf_size_needed(lv_obj_t * obj, lv_color_format_t cf)
|
|||||||
return lv_draw_buf_width_to_stride(w, cf) * h;
|
return lv_draw_buf_width_to_stride(w, cf) * h;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Take snapshot for object with its children, save image info to provided buffer.
|
/**
|
||||||
*
|
* Take snapshot for object with its children, save image info to provided buffer.
|
||||||
* @param obj The object to generate snapshot.
|
* @param obj the object to generate snapshot.
|
||||||
* @param cf color format for generated image.
|
* @param cf color format for generated image.
|
||||||
* @param dsc image descriptor to store the image result.
|
* @param dsc image descriptor to store the image result.
|
||||||
* @param buf the buffer to store image data.
|
* @param buf the buffer to store image data.
|
||||||
* @param buff_size provided buffer size in bytes.
|
* @param buff_size provided buffer size in bytes.
|
||||||
*
|
* @return LV_RESULT_OK on success, LV_RESULT_INVALID on error.
|
||||||
* @return LV_RESULT_OK on success, LV_RESULT_INVALID on error.
|
|
||||||
*/
|
*/
|
||||||
lv_result_t lv_snapshot_take_to_buf(lv_obj_t * obj, lv_color_format_t cf, lv_image_dsc_t * dsc, void * buf,
|
lv_result_t lv_snapshot_take_to_buf(lv_obj_t * obj, lv_color_format_t cf, lv_image_dsc_t * dsc, void * buf,
|
||||||
uint32_t buff_size)
|
uint32_t buff_size)
|
||||||
@@ -124,7 +122,6 @@ lv_result_t lv_snapshot_take_to_buf(lv_obj_t * obj, lv_color_format_t cf, lv_ima
|
|||||||
lv_layer_t layer;
|
lv_layer_t layer;
|
||||||
lv_memzero(&layer, sizeof(layer));
|
lv_memzero(&layer, sizeof(layer));
|
||||||
|
|
||||||
|
|
||||||
lv_draw_buf_init(&layer.draw_buf, dsc->header.w, dsc->header.h, dsc->header.cf);
|
lv_draw_buf_init(&layer.draw_buf, dsc->header.w, dsc->header.h, dsc->header.cf);
|
||||||
layer.draw_buf.buf = buf;
|
layer.draw_buf.buf = buf;
|
||||||
layer.draw_buf_ofs.x = snapshot_area.x1;
|
layer.draw_buf_ofs.x = snapshot_area.x1;
|
||||||
@@ -138,16 +135,14 @@ lv_result_t lv_snapshot_take_to_buf(lv_obj_t * obj, lv_color_format_t cf, lv_ima
|
|||||||
lv_draw_dispatch_layer(NULL, &layer);
|
lv_draw_dispatch_layer(NULL, &layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return LV_RESULT_OK;
|
return LV_RESULT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Take snapshot for object with its children, alloc the memory needed.
|
/**
|
||||||
*
|
* Take snapshot for object with its children, alloc the memory needed.
|
||||||
* @param obj The object to generate snapshot.
|
* @param obj the object to generate snapshot.
|
||||||
* @param cf color format for generated image.
|
* @param cf color format for generated image.
|
||||||
*
|
* @return a pointer to an image descriptor, or NULL if failed.
|
||||||
* @return a pointer to an image descriptor, or NULL if failed.
|
|
||||||
*/
|
*/
|
||||||
lv_image_dsc_t * lv_snapshot_take(lv_obj_t * obj, lv_color_format_t cf)
|
lv_image_dsc_t * lv_snapshot_take(lv_obj_t * obj, lv_color_format_t cf)
|
||||||
{
|
{
|
||||||
@@ -177,12 +172,10 @@ lv_image_dsc_t * lv_snapshot_take(lv_obj_t * obj, lv_color_format_t cf)
|
|||||||
return dsc;
|
return dsc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Free the snapshot image returned by @ref lv_snapshot_take
|
/**
|
||||||
*
|
* Free the snapshot image returned by @ref lv_snapshot_take
|
||||||
* It will firstly free the data image takes, then the image descriptor.
|
* It will firstly free the data image takes, then the image descriptor.
|
||||||
*
|
* @param dsc the image descriptor generated by lv_snapshot_take.
|
||||||
* @param dsc The image descriptor generated by lv_snapshot_take.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
void lv_snapshot_free(lv_image_dsc_t * dsc)
|
void lv_snapshot_free(lv_image_dsc_t * dsc)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,42 +31,37 @@ extern "C" {
|
|||||||
* GLOBAL PROTOTYPES
|
* GLOBAL PROTOTYPES
|
||||||
**********************/
|
**********************/
|
||||||
|
|
||||||
/** Take snapshot for object with its children.
|
/**
|
||||||
*
|
* Take snapshot for object with its children, alloc the memory needed.
|
||||||
* @param obj The object to generate snapshot.
|
* @param obj the object to generate snapshot.
|
||||||
* @param cf color format for generated image.
|
* @param cf color format for generated image.
|
||||||
*
|
* @return a pointer to an image descriptor, or NULL if failed.
|
||||||
* @return a pointer to an image descriptor, or NULL if failed.
|
|
||||||
*/
|
*/
|
||||||
lv_image_dsc_t * lv_snapshot_take(lv_obj_t * obj, lv_color_format_t cf);
|
lv_image_dsc_t * lv_snapshot_take(lv_obj_t * obj, lv_color_format_t cf);
|
||||||
|
|
||||||
/** Free the snapshot image returned by @ref lv_snapshot_take
|
/**
|
||||||
*
|
* Free the snapshot image returned by @ref lv_snapshot_take
|
||||||
* It will firstly free the data image takes, then the image descriptor.
|
* It will firstly free the data image takes, then the image descriptor.
|
||||||
*
|
* @param dsc the image descriptor generated by lv_snapshot_take.
|
||||||
* @param dsc The image descriptor generated by lv_snapshot_take.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
void lv_snapshot_free(lv_image_dsc_t * dsc);
|
void lv_snapshot_free(lv_image_dsc_t * dsc);
|
||||||
|
|
||||||
/** Get the buffer needed for object snapshot image.
|
/**
|
||||||
*
|
* Get the buffer needed for object snapshot image.
|
||||||
* @param obj The object to generate snapshot.
|
* @param obj the object to generate snapshot.
|
||||||
* @param cf color format for generated image.
|
* @param cf color format for generated image.
|
||||||
*
|
* @return the buffer size needed in bytes
|
||||||
* @return the buffer size needed in bytes
|
|
||||||
*/
|
*/
|
||||||
uint32_t lv_snapshot_buf_size_needed(lv_obj_t * obj, lv_color_format_t cf);
|
uint32_t lv_snapshot_buf_size_needed(lv_obj_t * obj, lv_color_format_t cf);
|
||||||
|
|
||||||
/** Take snapshot for object with its children, save image info to provided buffer.
|
/**
|
||||||
*
|
* Take snapshot for object with its children, save image info to provided buffer.
|
||||||
* @param obj The object to generate snapshot.
|
* @param obj the object to generate snapshot.
|
||||||
* @param cf color format for generated image.
|
* @param cf color format for generated image.
|
||||||
* @param dsc image descriptor to store the image result.
|
* @param dsc image descriptor to store the image result.
|
||||||
* @param buf the buffer to store image data.
|
* @param buf the buffer to store image data.
|
||||||
* @param buff_size provided buffer size in bytes.
|
* @param buff_size provided buffer size in bytes.
|
||||||
*
|
* @return LV_RESULT_OK on success, LV_RESULT_INVALID on error.
|
||||||
* @return LV_RESULT_OK on success, LV_RESULT_INVALID on error.
|
|
||||||
*/
|
*/
|
||||||
lv_result_t lv_snapshot_take_to_buf(lv_obj_t * obj, lv_color_format_t cf, lv_image_dsc_t * dsc, void * buf,
|
lv_result_t lv_snapshot_take_to_buf(lv_obj_t * obj, lv_color_format_t cf, lv_image_dsc_t * dsc, void * buf,
|
||||||
uint32_t buff_size);
|
uint32_t buff_size);
|
||||||
|
|||||||
@@ -55,10 +55,10 @@ static void lv_mem_walker(void * ptr, size_t size, int used, void * user);
|
|||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* MACROS
|
||||||
**********************/
|
**********************/
|
||||||
#if LV_LOG_TRACE_MEM
|
#if LV_USE_LOG && LV_LOG_TRACE_MEM
|
||||||
#define MEM_TRACE(...) LV_LOG_TRACE(__VA_ARGS__)
|
#define LV_TRACE_MEM(...) LV_LOG_TRACE(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define MEM_TRACE(...)
|
#define LV_TRACE_MEM(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define _COPY(d, s) *d = *s; d++; s++;
|
#define _COPY(d, s) *d = *s; d++; s++;
|
||||||
@@ -187,7 +187,7 @@ void lv_mem_monitor_core(lv_mem_monitor_t * mon_p)
|
|||||||
{
|
{
|
||||||
/*Init the data*/
|
/*Init the data*/
|
||||||
lv_memset(mon_p, 0, sizeof(lv_mem_monitor_t));
|
lv_memset(mon_p, 0, sizeof(lv_mem_monitor_t));
|
||||||
MEM_TRACE("begin");
|
LV_TRACE_MEM("begin");
|
||||||
|
|
||||||
lv_pool_t * pool_p;
|
lv_pool_t * pool_p;
|
||||||
_LV_LL_READ(&state.pool_ll, pool_p) {
|
_LV_LL_READ(&state.pool_ll, pool_p) {
|
||||||
@@ -205,7 +205,7 @@ void lv_mem_monitor_core(lv_mem_monitor_t * mon_p)
|
|||||||
|
|
||||||
mon_p->max_used = state.max_used;
|
mon_p->max_used = state.max_used;
|
||||||
|
|
||||||
MEM_TRACE("finished");
|
LV_TRACE_MEM("finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -233,7 +233,7 @@ lv_result_t lv_mem_test_core(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MEM_TRACE("passed");
|
LV_TRACE_MEM("passed");
|
||||||
#if LV_USE_OS
|
#if LV_USE_OS
|
||||||
lv_mutex_unlock(&state.mutex);
|
lv_mutex_unlock(&state.mutex);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -39,10 +39,10 @@
|
|||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* MACROS
|
||||||
**********************/
|
**********************/
|
||||||
#if LV_LOG_TRACE_MEM
|
#if LV_USE_LOG && LV_LOG_TRACE_MEM
|
||||||
#define MEM_TRACE(...) LV_LOG_TRACE(__VA_ARGS__)
|
#define LV_TRACE_MEM(...) LV_LOG_TRACE(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define MEM_TRACE(...)
|
#define LV_TRACE_MEM(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define _COPY(d, s) *d = *s; d++; s++;
|
#define _COPY(d, s) *d = *s; d++; s++;
|
||||||
|
|||||||
+10
-10
@@ -50,10 +50,10 @@ lv_result_t lv_mem_test_core(void);
|
|||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* MACROS
|
||||||
**********************/
|
**********************/
|
||||||
#if LV_LOG_TRACE_MEM
|
#if LV_USE_LOG && LV_LOG_TRACE_MEM
|
||||||
#define MEM_TRACE(...) LV_LOG_TRACE(__VA_ARGS__)
|
#define LV_TRACE_MEM(...) LV_LOG_TRACE(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define MEM_TRACE(...)
|
#define LV_TRACE_MEM(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
@@ -67,9 +67,9 @@ lv_result_t lv_mem_test_core(void);
|
|||||||
*/
|
*/
|
||||||
void * lv_malloc(size_t size)
|
void * lv_malloc(size_t size)
|
||||||
{
|
{
|
||||||
MEM_TRACE("allocating %lu bytes", (unsigned long)size);
|
LV_TRACE_MEM("allocating %lu bytes", (unsigned long)size);
|
||||||
if(size == 0) {
|
if(size == 0) {
|
||||||
MEM_TRACE("using zero_mem");
|
LV_TRACE_MEM("using zero_mem");
|
||||||
return &zero_mem;
|
return &zero_mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ void * lv_malloc(size_t size)
|
|||||||
lv_memset(alloc, 0xaa, size);
|
lv_memset(alloc, 0xaa, size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MEM_TRACE("allocated at %p", alloc);
|
LV_TRACE_MEM("allocated at %p", alloc);
|
||||||
|
|
||||||
return alloc;
|
return alloc;
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ void * lv_malloc(size_t size)
|
|||||||
*/
|
*/
|
||||||
void lv_free(void * data)
|
void lv_free(void * data)
|
||||||
{
|
{
|
||||||
MEM_TRACE("freeing %p", data);
|
LV_TRACE_MEM("freeing %p", data);
|
||||||
if(data == &zero_mem) return;
|
if(data == &zero_mem) return;
|
||||||
if(data == NULL) return;
|
if(data == NULL) return;
|
||||||
|
|
||||||
@@ -119,9 +119,9 @@ void lv_free(void * data)
|
|||||||
*/
|
*/
|
||||||
void * lv_realloc(void * data_p, size_t new_size)
|
void * lv_realloc(void * data_p, size_t new_size)
|
||||||
{
|
{
|
||||||
MEM_TRACE("reallocating %p with %lu size", data_p, (unsigned long)new_size);
|
LV_TRACE_MEM("reallocating %p with %lu size", data_p, (unsigned long)new_size);
|
||||||
if(new_size == 0) {
|
if(new_size == 0) {
|
||||||
MEM_TRACE("using zero_mem");
|
LV_TRACE_MEM("using zero_mem");
|
||||||
lv_free(data_p);
|
lv_free(data_p);
|
||||||
return &zero_mem;
|
return &zero_mem;
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ void * lv_realloc(void * data_p, size_t new_size)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
MEM_TRACE("reallocated at %p", new_p);
|
LV_TRACE_MEM("reallocated at %p", new_p);
|
||||||
return new_p;
|
return new_p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#define LV_MEM_SIZE (32 * 1024 * 1024)
|
#define LV_MEM_SIZE (32 * 1024 * 1024)
|
||||||
#define LV_LAYER_MAX_MEMORY_USAGE (4 * 1024)
|
#define LV_LAYER_MAX_MEMORY_USAGE (4 * 1024)
|
||||||
#define LV_USE_DRAW_MASKS 1
|
|
||||||
#define LV_SHADOW_CACHE_SIZE (8 * 1024)
|
#define LV_SHADOW_CACHE_SIZE (8 * 1024)
|
||||||
#define LV_IMAGE_CACHE_DEF_SIZE 32
|
#define LV_IMAGE_CACHE_DEF_SIZE 32
|
||||||
#define LV_USE_LOG 1
|
#define LV_USE_LOG 1
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#define LV_MEM_SIZE 65535
|
#define LV_MEM_SIZE 65535
|
||||||
#define LV_USE_DRAW_MASKS 0
|
|
||||||
#define LV_USE_METER 0
|
#define LV_USE_METER 0
|
||||||
#define LV_USE_LOG 1
|
#define LV_USE_LOG 1
|
||||||
#define LV_USE_ASSERT_NULL 0
|
#define LV_USE_ASSERT_NULL 0
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ test_img_lvgl_logo_jpg_map[] = {
|
|||||||
0x05, 0x00, 0x14, 0x00, 0x50, 0x01, 0x40, 0x1f, 0xff, 0xd9
|
0x05, 0x00, 0x14, 0x00, 0x50, 0x01, 0x40, 0x1f, 0xff, 0xd9
|
||||||
};
|
};
|
||||||
|
|
||||||
const lv_img_dsc_t test_img_lvgl_logo_jpg = {
|
const lv_image_dsc_t test_img_lvgl_logo_jpg = {
|
||||||
.header.cf = LV_COLOR_FORMAT_RAW,
|
.header.cf = LV_COLOR_FORMAT_RAW,
|
||||||
.header.always_zero = 0,
|
.header.always_zero = 0,
|
||||||
.header.reserved = 0,
|
.header.reserved = 0,
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ test_img_lvgl_logo_png_map[] = {
|
|||||||
0x82
|
0x82
|
||||||
};
|
};
|
||||||
|
|
||||||
const lv_img_dsc_t test_img_lvgl_logo_png = {
|
const lv_image_dsc_t test_img_lvgl_logo_png = {
|
||||||
.header.cf = LV_COLOR_FORMAT_RAW_ALPHA,
|
.header.cf = LV_COLOR_FORMAT_RAW_ALPHA,
|
||||||
.header.always_zero = 0,
|
.header.always_zero = 0,
|
||||||
.header.reserved = 0,
|
.header.reserved = 0,
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ static void canvas_draw(const char * name, lv_color_format_t large_render_cf)
|
|||||||
lv_canvas_set_buffer(canvas2, canvas2_buf, 770, 390, large_render_cf);
|
lv_canvas_set_buffer(canvas2, canvas2_buf, 770, 390, large_render_cf);
|
||||||
lv_canvas_fill_bg(canvas2, lv_palette_lighten(LV_PALETTE_BLUE_GREY, 2), LV_OPA_COVER);
|
lv_canvas_fill_bg(canvas2, lv_palette_lighten(LV_PALETTE_BLUE_GREY, 2), LV_OPA_COVER);
|
||||||
|
|
||||||
lv_img_dsc_t img = { 0 };
|
lv_image_dsc_t img = { 0 };
|
||||||
img.header.w = 180;
|
img.header.w = 180;
|
||||||
img.header.h = 180;
|
img.header.h = 180;
|
||||||
img.header.stride = 0;
|
img.header.stride = 0;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user