Skip to content

Commit 0c5d674

Browse files
Fix jpeg support
1 parent 51be28f commit 0c5d674

File tree

1 file changed

+9
-23
lines changed
  • internal_filesystem/apps/com.micropythonos.imageview/assets

1 file changed

+9
-23
lines changed

internal_filesystem/apps/com.micropythonos.imageview/assets/imageview.py

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ class ImageView(Activity):
1313
image_nr = 0
1414
image_timer = None
1515
image = None
16-
image_dsc = None
1716

1817
def onCreate(self):
1918
screen = lv.obj()
@@ -23,8 +22,6 @@ def onCreate(self):
2322
self.image = lv.image(screen)
2423
self.image.set_size(128, 128)
2524
self.image.align(lv.ALIGN.BOTTOM_MID,0,0)
26-
self.image_dsc = lv.image_dsc_t()
27-
self.image.set_src(self.image_dsc)
2825
self.setContentView(screen)
2926

3027
def onResume(self, screen):
@@ -68,26 +65,15 @@ def show_next_image(self, event):
6865
def show_image(self, name):
6966
try:
7067
self.label.set_text(name)
71-
f = open(name, 'rb')
72-
image_data = f.read()
73-
print(f"loaded {len(image_data)} bytes")
74-
f.close()
75-
#self.image_dsc.data_size = len(image_data)
76-
#self.image_dsc.data = image_data
77-
self.image_dsc = None
78-
#self.image.set_src(self.image_dsc)
79-
self.image_dsc = lv.image_dsc_t({
80-
'data_size': len(image_data),
81-
'data': image_data
82-
})
83-
h = lv.image_header_t()
84-
lv.image.decoder_get_info(self.image_dsc, h)
85-
print("image info:")
86-
print(h)
87-
print(f"widthxheight: {h.w}x{h.h}")
88-
self.image.set_src(self.image_dsc)
68+
self.image.set_src(f"P:{name}")
69+
w = self.image.get_width()
70+
h = self.image.get_height()
71+
print(f"the LVGL image has size: {w}x{h}")
72+
header = lv.image_header_t()
73+
self.image.decoder_get_info(self.image.get_src(), header)
74+
print(f"the real image has size: {header.w}x{header.h}")
8975
#image.set_size(128, 128)
90-
#image.set_scale(512)
91-
print(f"done with show_image({name})")
76+
self.image.set_scale(512)
77+
print(f"done with show_image({name}) got {w}x{h}")
9278
except Exception as e:
9379
print(f"show_image got exception: {e}")

0 commit comments

Comments
 (0)