Skip to content

Instantly share code, notes, and snippets.

@oddstr13
Created October 5, 2019 01:08
Show Gist options
  • Save oddstr13/8be1533f769379c63d1f9eaa1c0ff781 to your computer and use it in GitHub Desktop.
Save oddstr13/8be1533f769379c63d1f9eaa1c0ff781 to your computer and use it in GitHub Desktop.
import sys
with open(sys.argv[1], "rb") as file:
file.seek(0x1c)
color_depth = file.read(1)[0] | file.read(1)[0] << 8
print("Color depth:", color_depth)
file.seek(0x1e)
compression = file.read(1)[0] | file.read(1)[0] << 8
print("Compression:", compression)
file.seek(0x2e)
colors = file.read(1)[0] | file.read(1)[0] << 8 | file.read(1)[0] << 16 | file.read(1)[0] << 24
print("Colors:", colors)
print("Is true color BMP: ", colors == 0 and color_depth >= 16)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment