How to Return the Pixel Dimensions and Depth of a Bitmap
Keywords: bitmap dimensions
Question:
Do you know of a way to return the pixel dimensions and depth (no. of
colors) of a .BMP file? I realize that this is a long shot, but what the heck, thought I'd ask anyway.
Thanks.
Answer:
bmp="c:\incoming\studio16.bmp"
bmpsize=FileSize(bmp)
bb=BinaryAlloc(bmpsize)
BinaryRead(bb,bmp)
height=BinaryPeek4(bb,18)
width=BinaryPeek4(bb,22)
BinaryFree(bb)
Message(bmp,"%height% x %width%")
By the way, color depth is at the 28th byte (1C hexadecimal):
bits = BinaryPeek2(bb,28)
Article ID: W12745
Filename: How to Return Bitmap Dimensions.txt