1#!/opt/bin/lv_micropython -i
2import usys as sys
3import lvgl as lv
4import display_driver
5from imagetools import get_png_info, open_png
6
7# Register PNG image decoder
8decoder = lv.img.decoder_create()
9decoder.info_cb = get_png_info
10decoder.open_cb = open_png
11
12# Create an image from the png file
13try:
14    with open('../../assets/img_cogwheel_argb.png','rb') as f:
15        png_data = f.read()
16except:
17    print("Could not find img_cogwheel_argb.png")
18    sys.exit()
19
20img_cogwheel_argb = lv.img_dsc_t({
21  'data_size': len(png_data),
22  'data': png_data
23})
24
25img1 = lv.img(lv.scr_act())
26img1.set_src(img_cogwheel_argb)
27img1.align(lv.ALIGN.CENTER, 0, -20)
28img1.set_size(200, 200)
29
30img2 = lv.img(lv.scr_act())
31img2.set_src(lv.SYMBOL.OK + "Accept")
32img2.align_to(img1, lv.ALIGN.OUT_BOTTOM_MID, 0, 20)
33