File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ def load(
48
48
:param object palette: Type to store the palette. Must have API similar to
49
49
`displayio.Palette`. Will be skipped if None.
50
50
"""
51
- # pylint: disable=too-many-locals,too-many-branches
51
+ # pylint: disable=too-many-locals,too-many-branches, consider-using-enumerate, too-many-statements
52
52
header = file .read (8 )
53
53
if header != b"\x89 PNG\r \n \x1a \n " :
54
54
raise ValueError ("Not a PNG file" )
@@ -87,10 +87,12 @@ def load(
87
87
for i in range (pal_size ):
88
88
pal [i ] = file .read (3 )
89
89
elif chunk == b"tRNS" :
90
- trns_list = list (file .read (size ))
91
- indices = [i for i , x in enumerate (trns_list ) if x == 0 ]
92
- for index in indices :
93
- pal .make_transparent (index )
90
+ if size > len (pal ):
91
+ raise ValueError ("More transparency entries than palette entries" )
92
+ trns_data = file .read (size )
93
+ for i in range (len (trns_data )):
94
+ if trns_data [i ] == 0 :
95
+ pal .make_transparent (i )
94
96
elif chunk == b"IDAT" :
95
97
data .extend (file .read (size ))
96
98
elif chunk == b"IEND" :
You can’t perform that action at this time.
0 commit comments