Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long Private Const OBJ_BITMAP = 7 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 TypeSub GetBmpInfo() Dim bmp As BITMAP
GetObject Me.Picture.Handle, Len(bmp), bmp End Sub BITMAP结构里已包含图像的所有信息了。
Private Declare Function GetObject 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 TypeSub GetBmpInfo() Dim bmp As BITMAP
GetObject Me.Picture.Handle, Len(bmp), bmp End Sub BITMAP结构里已包含图像的所有信息了。
我用过这个方法 Dim tmpPic As Picture Set tmpPic = CaptureWindow(hWndActive, False, x, y, x + w, y + h) '获取图片 Dim PBag As New PropertyBag Dim B() As Byte PBag.WriteProperty "Picture", tmpPic '读取tmpPicture 图片并写到 Pbag 容器中
B = PBag.Contents '获取容器Byte 到 B() 数组中 Set PBag = Nothing不过得到的数组B 好像不对 大小比通过GetBitmapBits得到的数组还小 , 而且在C#里面不能转换成图片
我试了一下, Dim PBag As New PropertyBag Dim B() As Byte PBag.WriteProperty "Picture", tmpPic '读取tmpPicture 图片并写到 Pbag 容器中
B = PBag.Contents '获取容器Byte 到 B() 数组中 得到的数据已不是原来的数据,就在本程序段已不能加载为图片
Private Const OBJ_BITMAP = 7
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 TypeSub GetBmpInfo()
Dim bmp As BITMAP
GetObject Me.Picture.Handle, Len(bmp), bmp
End Sub
BITMAP结构里已包含图像的所有信息了。
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 TypeSub GetBmpInfo()
Dim bmp As BITMAP
GetObject Me.Picture.Handle, Len(bmp), bmp
End Sub
BITMAP结构里已包含图像的所有信息了。
是的, 我不是说用GetBitmapBits获取所有, 其他方法的只要能取到所有数据就可以
我用过这个方法
Dim tmpPic As Picture
Set tmpPic = CaptureWindow(hWndActive, False, x, y, x + w, y + h) '获取图片
Dim PBag As New PropertyBag
Dim B() As Byte
PBag.WriteProperty "Picture", tmpPic '读取tmpPicture 图片并写到 Pbag 容器中
B = PBag.Contents '获取容器Byte 到 B() 数组中
Set PBag = Nothing不过得到的数组B 好像不对 大小比通过GetBitmapBits得到的数组还小 , 而且在C#里面不能转换成图片
Dim PBag As New PropertyBag
Dim B() As Byte
PBag.WriteProperty "Picture", tmpPic '读取tmpPicture 图片并写到 Pbag 容器中
B = PBag.Contents '获取容器Byte 到 B() 数组中
得到的数据已不是原来的数据,就在本程序段已不能加载为图片