Skip to content

Commit 6fb1375

Browse files
author
bstorm
committed
commiting what's broken
1 parent 51cf99e commit 6fb1375

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

adafruit_imageload/pnm/ppm/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def load(file, magic_number, header, bitmap=None, palette=None):
4242
width = header[0]
4343
height = header[1]
4444
max_colors = (header[2] + 1) ** 3
45+
# TODO: This needs to be different most likely?
4546
colors = math.log(header[2], 2)
4647
bitmap = bitmap(width, height, int(colors))
4748
palette = None
@@ -59,16 +60,19 @@ def load(file, magic_number, header, bitmap=None, palette=None):
5960
while max_colors > 2 ** minimum_color_depth:
6061
minimum_color_depth *= 2
6162

63+
# This seems maybe right?
6264
line_size = width * 3
6365

6466
chunk = bytearray(line_size)
6567

6668
for y in range(height):
6769
file.readinto(chunk)
70+
# Division by zero!
6871
pixels_per_byte = 8 // max_colors
6972
offset = y * width
7073

7174
for x in range(width):
75+
# This math is clearly wrong and was just copied in from the PR
7276
i = x // pixels_per_byte
7377
pixel = (
7478
chunk[i] >> (8 - max_colors * (x % pixels_per_byte + 1))

0 commit comments

Comments
 (0)