LB Booster
General >> General Board >> Size of a BMP Image
http://lbb.conforums.com/index.cgi?board=general&action=display&num=1443808178

Size of a BMP Image
Post by Jack Kelly on Oct 2nd, 2015, 5:49pm

Does anyone know how to determine the pixel dimensions of a .BMP image so it can be centered with the DrawBMP command if desired?
Re: Size of a BMP Image
Post by tsh73 on Oct 2nd, 2015, 6:14pm

http://lbpe.wikispaces.com/GraphicDimensions
Re: Size of a BMP Image
Post by Richard Russell on Oct 2nd, 2015, 7:42pm

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.
Re: Size of a BMP Image
Post by Jack Kelly on Oct 3rd, 2015, 07:01am

Thank you both for your suggestions. Both methods look good to me. As always, your help is greatly appreciated.