首先获得一个图片对象
1 Dim spic As StdPicture 2 Set spic = LoadPicture("d:\0.bmp") '从文件获得 3 Set spic = Clipboard.GetData '从粘贴板获得
方法一:
Dim w As Long, h As Long w = spic.Width/ 26.4591
h = spic.Height/ 26.4591
方法二:
Dim w As Long, h As Long w = ScaleX(spic.Width, vbHimetric, vbPixels) h = ScaleY(spic.Height, vbHimetric, vbPixels)
方法三:
'声明API Private Declare Function GdiGetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long Private Type BITMAP '14 bytes bmType As Long bmWidth As Long bmHeight As Long bmWidthBytes As Long bmPlanes As Integer bmBitsPixel As Integer bmBits As Long End Type '过程中 Dim w As Long, h As Long,bmp As BITMAP GdiGetObject spic, Len(bmp), bmp w = bmp.bmWidth h = bmp.bmHeight