Skip to content

Commit 21755ff

Browse files
committed
Revert "refactor negative height check into its own file"
This reverts commit 42fda8a.
1 parent 42fda8a commit 21755ff

File tree

3 files changed

+5
-26
lines changed

3 files changed

+5
-26
lines changed

adafruit_imageload/bmp/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,7 @@ def load(file, *, bitmap=None, palette=None):
5050
# print(bmp_header_length)
5151
file.seek(0x12) # Width of the bitmap in pixels
5252
width = int.from_bytes(file.read(4), "little")
53-
try:
54-
height = int.from_bytes(file.read(4), "little")
55-
except OverflowError:
56-
raise NotImplementedError(
57-
"Negative height BMP files are not supported on builds without longint"
58-
)
59-
53+
height = int.from_bytes(file.read(4), "little")
6054
file.seek(0x1C) # Number of bits per pixel
6155
color_depth = int.from_bytes(file.read(2), "little")
6256
file.seek(0x1E) # Compression type

adafruit_imageload/bmp/indexed.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@
2929
3030
"""
3131

32-
__version__ = "0.10.0"
32+
__version__ = "0.0.0-auto.0"
3333
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad.git"
3434

35-
import sys
36-
3735

3836
def load(
3937
file,
@@ -73,12 +71,9 @@ def load(
7371
while colors > 2 ** minimum_color_depth:
7472
minimum_color_depth *= 2
7573

76-
if sys.maxsize > 1073741823:
77-
# pylint: disable=import-outside-toplevel
78-
from negative_height_check import negative_height_check
79-
80-
# convert unsigned int to signed int when height is negative
81-
height = negative_height_check(height)
74+
# convert unsigned int to signed int when height is negative
75+
if height > 0x7FFFFFFF:
76+
height = height - 4294967296
8277
bitmap = bitmap(width, abs(height), colors)
8378
file.seek(data_start)
8479
line_size = width // (8 // color_depth)

adafruit_imageload/bmp/negative_height_check.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)