Skip to content

Commit e44e1d2

Browse files
committed
temp
1 parent a9c548d commit e44e1d2

12 files changed

Lines changed: 9564 additions & 19 deletions

File tree

DASH/Drivers/lvgl/examples/libs/png/img_wink_png.c

Lines changed: 348 additions & 0 deletions
Large diffs are not rendered by default.

DASH/Drivers/lvgl/examples/libs/png/img_wink_png.py

Lines changed: 337 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Open a PNG image from file and variable
2+
"""""""""""""""""""""""""""""""""""""""""""""""
3+
4+
.. lv_example:: libs/png/lv_example_png_1
5+
:language: c
6+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* @file lv_example_png.h
3+
*
4+
*/
5+
6+
#ifndef LV_EXAMPLE_PNG_H
7+
#define LV_EXAMPLE_PNG_H
8+
9+
#ifdef __cplusplus
10+
extern "C" {
11+
#endif
12+
13+
/*********************
14+
* INCLUDES
15+
*********************/
16+
17+
/*********************
18+
* DEFINES
19+
*********************/
20+
21+
/**********************
22+
* TYPEDEFS
23+
**********************/
24+
25+
/**********************
26+
* GLOBAL PROTOTYPES
27+
**********************/
28+
void lv_example_png_1(void);
29+
30+
/**********************
31+
* MACROS
32+
**********************/
33+
34+
#ifdef __cplusplus
35+
} /*extern "C"*/
36+
#endif
37+
38+
#endif /*LV_EXAMPLE_PNG_H*/
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include "../../lv_examples.h"
2+
#if LV_USE_PNG && LV_USE_IMG && LV_BUILD_EXAMPLES
3+
4+
/**
5+
* Open a PNG image from a file and a variable
6+
*/
7+
void lv_example_png_1(void)
8+
{
9+
LV_IMG_DECLARE(img_wink_png);
10+
lv_obj_t * img;
11+
12+
img = lv_img_create(lv_scr_act());
13+
lv_img_set_src(img, &img_wink_png);
14+
lv_obj_align(img, LV_ALIGN_LEFT_MID, 20, 0);
15+
16+
img = lv_img_create(lv_scr_act());
17+
/* Assuming a File system is attached to letter 'A'
18+
* E.g. set LV_USE_FS_STDIO 'A' in lv_conf.h */
19+
lv_img_set_src(img, "A:lvgl/examples/libs/png/wink.png");
20+
lv_obj_align(img, LV_ALIGN_RIGHT_MID, -20, 0);
21+
}
22+
23+
#endif
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/opt/bin/lv_micropython -i
2+
import lvgl as lv
3+
import display_driver
4+
from imagetools import get_png_info, open_png
5+
from img_wink_png import img_wink_png_map
6+
# Register PNG image decoder
7+
decoder = lv.img.decoder_create()
8+
decoder.info_cb = get_png_info
9+
decoder.open_cb = open_png
10+
11+
img_wink_png = lv.img_dsc_t(
12+
{
13+
"header": {"always_zero": 0, "w": 50, "h": 50, "cf": lv.img.CF.RAW_ALPHA},
14+
"data_size": 5158,
15+
"data": img_wink_png_map,
16+
}
17+
)
18+
img1 = lv.img(lv.scr_act())
19+
img1.set_src(img_wink_png)
20+
img1.align(lv.ALIGN.RIGHT_MID, -250, 0)
21+
22+
# Create an image from the png file
23+
try:
24+
with open('wink.png','rb') as f:
25+
png_data = f.read()
26+
except:
27+
print("Could not find wink.png")
28+
sys.exit()
29+
30+
wink_argb = lv.img_dsc_t({
31+
'data_size': len(png_data),
32+
'data': png_data
33+
})
34+
35+
img2 = lv.img(lv.scr_act())
36+
img2.set_src(wink_argb)
37+
img2.align(lv.ALIGN.RIGHT_MID, -150, 0)
5.04 KB
Loading

0 commit comments

Comments
 (0)