Skip to content

Commit d4e33c2

Browse files
committed
save progress
1 parent 95fce9e commit d4e33c2

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

adafruit_imageload/pnm/pgm/__init__.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,27 @@ def load(f, magic_number, header, *, bitmap=None, palette=None):
3535
height = header[1]
3636
max_colors = header[2] + 1
3737
min_color = 1 # probably don't need this
38+
columns = height
3839
line_length = width //(8 // max_colors)
3940
bitmap = bitmap(width, height, max_colors)
4041

4142

4243
if max_color > 256:
4344
# raise exception
45+
raise NotImplementedError("16 bit grayscale not supported")
4446

4547
if magic_number == "P2":
46-
# Convert ascii to Bits
47-
48+
# Handle ascii
49+
for x in height:
50+
for y in line_length:
51+
# Takes int and converts to an 8 bit
52+
53+
bitmap[x,y] = format(inttoformat,'08b')
4854

4955

56+
57+
if magic_number == "P5":
58+
5059
# Assign bits to bitmap
5160

5261
# create pallete
@@ -59,7 +68,7 @@ def load(f, magic_number, header, *, bitmap=None, palette=None):
5968

6069
# Example bitmap object:
6170
# [
62-
# [(222), (33), 5), (76), (55), (82)]
71+
# [(222), (33), (5), (76), (55), (82)]
6372
# ]
6473

6574

0 commit comments

Comments
 (0)