@@ -24,7 +24,7 @@ def onCreate(self):
2424 self .image .center ()
2525 self .image .add_flag (lv .obj .FLAG .CLICKABLE )
2626 #self.image.add_event_cb(self.print_events, lv.EVENT.ALL, None)
27- # self.image.add_event_cb(lambda e: self.toggle_fullscreen(),lv.EVENT.CLICKED,None)
27+ self .image .add_event_cb (lambda e : self .toggle_fullscreen (),lv .EVENT .CLICKED ,None )
2828 self .label = lv .label (screen )
2929 self .label .set_text ('Loading images from\n {self.imagedir}' )
3030 self .label .align (lv .ALIGN .TOP_MID ,0 ,0 )
@@ -57,7 +57,7 @@ def onResume(self, screen):
5757 self .images .clear ()
5858 for item in os .listdir (self .imagedir ):
5959 print (item )
60- if item .endswith (".jpg" ) or item .endswith (".jpeg" ) or item .endswith (".png" ):
60+ if item .endswith (".jpg" ) or item .endswith (".jpeg" ) or item .endswith (".png" ) or item . endswith ( ".raw" ) :
6161 fullname = f"{ self .imagedir } /{ item } "
6262 size = os .stat (fullname )[6 ]
6363 print (f"size: { size } " )
@@ -178,7 +178,27 @@ def show_next_image(self, event=None):
178178 def show_image (self , name ):
179179 try :
180180 self .label .set_text (name )
181- self .image .set_src (f"M:{ name } " )
181+ if name .endswith (".raw" ):
182+ f = open (name , 'rb' )
183+ image_data = f .read ()
184+ print (f"loaded { len (image_data )} bytes" )
185+ f .close ()
186+ w = 240
187+ h = 240
188+ image_dsc = lv .image_dsc_t ({
189+ "header" : {
190+ "magic" : lv .IMAGE_HEADER_MAGIC ,
191+ "w" : w ,
192+ "h" : h ,
193+ "stride" : w * 2 ,
194+ "cf" : lv .COLOR_FORMAT .RGB565
195+ },
196+ 'data_size' : w * h * 2 ,
197+ 'data' : image_data
198+ })
199+ self .image .set_src (image_dsc )
200+ else :
201+ self .image .set_src (f"M:{ name } " )
182202 self .scale_image ()
183203 except Exception as e :
184204 print (f"show_image got exception: { e } " )
0 commit comments