Skip to content

Commit ce05f6b

Browse files
author
Matt Land
committed
.
1 parent 0b94799 commit ce05f6b

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

adafruit_imageload/tests/displayio_shared_bindings.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ def __init__(self, width, height, colors):
1111
self.data = {}
1212

1313
def _abs_pos(self, width: int, height: int) -> int:
14-
if height > self.height - 1:
14+
if height >= self.height:
1515
raise ValueError("height > max")
16-
if width > self.width - 1:
16+
if width >= self.width:
1717
raise ValueError("width > max")
1818
return width + (height * self.width)
1919

@@ -25,11 +25,9 @@ def __setitem__(self, key: tuple, value: int):
2525
# order is X, Y from the docs https://github.com/adafruit/circuitpython/blob/master/shared-bindings/displayio/Bitmap.c
2626
self.__setitem__(self._abs_pos(key[0], key[1]), value)
2727
return
28-
if not isinstance(value, (int,bytes)):
28+
if not isinstance(value, (int)):
2929
raise RuntimeError(f"set value as int or bytes, not {type(value)}")
30-
if isinstance(value, int) and value > 255:
31-
raise ValueError(f'pixel value {value} too large')
32-
if isinstance(value, bytes) and value > b'\xff':
30+
if value > 255:
3331
raise ValueError(f'pixel value {value} too large')
3432
self.data[key] = value
3533

0 commit comments

Comments
 (0)