on Oct 2nd, 2015, 5:49pm, Jack Kelly wrote:Does anyone know how to determine the pixel dimensions of a .BMP image so it can be centered with the DrawBMP command if desired? |
|
Here you go:
Code: loadbmp "bitmap", "myimage.bmp"
hbitmap = hbmp("bitmap")
struct bitmap, bmType as long, bmWidth as long, bmHeight as long, _
bmWidthBytes as long, bmPlanes as short, bmBitsPixel as short, _
bmBits as ulong
bitmaplen = len(bitmap.struct)
calldll #gdi32, "GetObjectA", hbitmap as ulong, _
bitmaplen as long, bitmap as struct, ret as long
print "Width is "; bitmap.bmWidth.struct
print "Height is "; bitmap.bmHeight.struct
I'm personally not keen on methods that involve peeking the file, and since you're likely to want to loadbmp the image anyway the above method seems more direct.
Richard.