VB Image

Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Dim a As String, k As Single
Private Type BITMAP
    bmType As Long
    bmWidth As Long
    bmHeight As Long
    bmWidthBytes As Long
    bmPlanes As Integer
    bmBitsPixel As Integer
    bmBits As Long
End Type

Private Type PicInfo
    PicWidth As Long
    picHeight As Long
End Type

Private Function fncGetInfo(lsPicName As String) As PicInfo
'lsPicName是图片的文件名,带路径
    Dim hBitmap As Long
    Dim res As Long
    Dim bmp As BITMAP
    res = GetObject(LoadPicture(lsPicName).Handle, Len(bmp), bmp) '取得BITMAP的结构
    fncGetInfo.PicWidth = bmp.bmWidth  '图片的宽
    fncGetInfo.picHeight = bmp.bmHeight '图片的高
End Function

引用:
   Print fncGetInfo("c:\景色1.jpg").PicWidth
   Print fncGetInfo("c:\景色1.jpg").picHeight

你可能感兴趣的:(C++,c,C#,vb)