1from imagetools import get_png_info, open_png
2# Register PNG image decoder
3decoder = lv.img.decoder_create()
4decoder.info_cb = get_png_info
5decoder.open_cb = open_png
6
7# Create an image from the png file
8try:
9    with open('../assets/img_cogwheel_argb.png', 'rb') as f:
10        png_data = f.read()
11except:
12    print("Could not find img_cogwheel_argb.png")
13    sys.exit()
14
15img_cogwheel_argb = lv.img_dsc_t({
16  'data_size': len(png_data),
17  'data': png_data
18})
19
20#
21# Using the Image style properties
22#
23style = lv.style_t()
24style.init()
25
26# Set a background color and a radius
27style.set_radius(5)
28style.set_bg_opa(lv.OPA.COVER)
29style.set_bg_color(lv.palette_lighten(lv.PALETTE.GREY, 3))
30style.set_border_width(2)
31style.set_border_color(lv.palette_main(lv.PALETTE.BLUE))
32
33style.set_img_recolor(lv.palette_main(lv.PALETTE.BLUE))
34style.set_img_recolor_opa(lv.OPA._50)
35# style.set_transform_angle(300)
36
37# Create an object with the new style
38obj = lv.img(lv.scr_act())
39obj.add_style(style, 0)
40
41obj.set_src(img_cogwheel_argb)
42
43obj.center()
44