Skip to content

Commit 8d93f80

Browse files
committed
Use hex offsets
1 parent 5521a2e commit 8d93f80

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

adafruit_imageload/bmp/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ def load(file, *, bitmap=None, palette=None):
4646
# f.seek(14)
4747
# bmp_header_length = int.from_bytes(file.read(4), 'little')
4848
# print(bmp_header_length)
49-
file.seek(18)
49+
file.seek(0x12) # Width of the bitmap in pixels
5050
width = int.from_bytes(file.read(4), 'little')
5151
height = int.from_bytes(file.read(4), 'little')
52-
file.seek(28)
52+
file.seek(0x1c) # Number of bits per pixel
5353
color_depth = int.from_bytes(file.read(2), 'little')
54-
file.seek(46)
54+
file.seek(0x2e) # Number of colors in the color palette
5555
colors = int.from_bytes(file.read(4), 'little')
5656

5757
if colors == 0 and color_depth >= 16:

0 commit comments

Comments
 (0)