Skip to content

Commit f47d201

Browse files
author
bstorm
committed
We support 16 bits now
1 parent 70b707b commit f47d201

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

adafruit_imageload/pnm/__init__.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ def load(f, header, *, bitmap=None, palette=None):
4141
while True:
4242
# We have all we need at length 3
4343
if len(pnm_header) == 3:
44-
test_byte = f.read(1)
45-
if test_byte.isdigit():
46-
raise RuntimeError("Not supporting 16-bit colors at this time")
44+
f.read(1)
4745
break
4846
if magic_number.startswith(b"P1") or magic_number.startswith(b"P4"):
4947
if len(pnm_header) == 2:
@@ -63,16 +61,16 @@ def load(f, header, *, bitmap=None, palette=None):
6361
if next_byte == b"\n":
6462
break
6563
if next_byte.isdigit():
66-
value = bytesarray()
64+
value = bytearray()
6765
while True:
6866
if not next_byte.isdigit():
6967
break
70-
value.append(next_byte)
68+
value += next_byte
7169
next_byte = f.read(1)
7270
if not next_byte:
7371
raise RuntimeError("Unsupported image format")
7472

75-
pnm_header.append(int.from_bytes(value, "big"))
73+
pnm_header.append(int(value))
7674
continue
7775

7876
if not next_byte:

0 commit comments

Comments
 (0)