File tree Expand file tree Collapse file tree 1 file changed +27
-8
lines changed Expand file tree Collapse file tree 1 file changed +27
-8
lines changed Original file line number Diff line number Diff line change @@ -88,14 +88,33 @@ def load(
8888 if compression == 0 :
8989
9090 if _bitmap_readinto :
91- _bitmap_readinto (
92- bitmap ,
93- file ,
94- bits_per_pixel = color_depth ,
95- element_size = 4 ,
96- reverse_pixels_in_element = True ,
97- reverse_rows = True ,
98- )
91+ try :
92+ _bitmap_readinto (
93+ bitmap ,
94+ file ,
95+ bits_per_pixel = color_depth ,
96+ element_size = 4 ,
97+ reverse_pixels_in_element = True ,
98+ reverse_rows = True ,
99+ )
100+ except TypeError :
101+ # catch unexpected argument, try python read code.
102+ # This issue affects only CircuitPython 6.2.0-beta.4.
103+ # The try/except block here should be removed when
104+ # a newer release is made.
105+ chunk = bytearray (line_size )
106+ for y in range (range1 , range2 , range3 ):
107+ file .readinto (chunk )
108+ pixels_per_byte = 8 // color_depth
109+ offset = y * width
110+
111+ for x in range (width ):
112+ i = x // pixels_per_byte
113+ pixel = (
114+ chunk [i ]
115+ >> (8 - color_depth * (x % pixels_per_byte + 1 ))
116+ ) & mask
117+ bitmap [offset + x ] = pixel
99118 else : # use the standard file.readinto
100119 chunk = bytearray (line_size )
101120 for y in range (range1 , range2 , range3 ):
You can’t perform that action at this time.
0 commit comments