Older Version
Newer Version
Alyce
Jan 7, 2006
Get Bitmap Dimensions - one of the most often-asked questions is "How do I get the dimensions of a Bitmap?" This method shows a simple way to do it with API calls. It requires a struct, and it also requires that you load the bitmap with loadbmp and get its handle with hbmp()
-
Alyce Jan 7, 2006
- Alyce Jan 7, 2006
-
struct BITMAP,_
bmType as long,_
bmWidth As long,_
bmHeight As long,_
bmWidthBytes As long,_
bmPlanes as word,_
bmBitsPixel as word,_
bmBits as Long
filedialog "Open","*.bmp",bmp$
if bmp$="" then end
loadbmp "testbmp",bmp$
hTest=hbmp("testbmp")
print BitmapWidth(hTest)
print BitmapHeight(hTest)
unloadbmp "testbmp"
END
Function BitmapWidth(hBmp)
length=len(BITMAP.struct)
calldll #gdi32, "GetObjectA", hBmp as ulong,_
length as long,BITMAP as struct,_
results as long
BitmapWidth=BITMAP.bmWidth.struct
End Function
Function BitmapHeight(hBmp)
length=len(BITMAP.struct)
calldll #gdi32, "GetObjectA", hBmp as ulong,_
length as long,BITMAP as struct,_
results as long
BitmapHeight=BITMAP.bmHeight.struct
End Function