1#!/opt/bin/lv_micropython -i
2import lvgl as lv
3import display_driver
4from imagetools import get_png_info, open_png
5from img_wink_png import img_wink_png_map
6# Register PNG image decoder
7decoder = lv.img.decoder_create()
8decoder.info_cb = get_png_info
9decoder.open_cb = open_png
10
11img_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)
18img1 = lv.img(lv.scr_act())
19img1.set_src(img_wink_png)
20img1.align(lv.ALIGN.RIGHT_MID, -250, 0)
21
22# Create an image from the png file
23try:
24    with open('wink.png','rb') as f:
25        png_data = f.read()
26except:
27    print("Could not find wink.png")
28    sys.exit()
29
30wink_argb = lv.img_dsc_t({
31  'data_size': len(png_data),
32  'data': png_data
33})
34
35img2 = lv.img(lv.scr_act())
36img2.set_src(wink_argb)
37img2.align(lv.ALIGN.RIGHT_MID, -150, 0)
38