求救——怎样读取粘贴板上的数据

liuyan4794 2003-10-21 08:57:29
粘贴板上有一副BMP图片,怎样将粘贴板上(图片)的数据赋值给一个数组
...全文
150 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
fishmans 2003-10-25
  • 打赏
  • 举报
回复
直接用clipboard。getdate应该可以了
example:
picture1.picture=clipboard.getdata
rainstormmaster 2003-10-25
  • 打赏
  • 举报
回复
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 Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Private Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long
Private Declare Function SetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long
Dim PicBits() As Byte, PicInfo As BITMAP, Cnt As Long
Private Sub Command1_Click()
Set Picture1.Picture = Clipboard.GetData(vbCFBitmap)
GetObject Picture1.Picture, Len(PicInfo), PicInfo
'reallocate storage space
Debug.Print PicInfo.bmWidth * PicInfo.bmHeight * 3
ReDim PicBits(1 To PicInfo.bmWidth * PicInfo.bmHeight * 3) As Byte
'Copy the bitmapbits to the array
GetBitmapBits Picture1.Picture, UBound(PicBits), PicBits(1)
'Invert the bits
For Cnt = 1 To UBound(PicBits)
PicBits(Cnt) = 255 - PicBits(Cnt)
Next Cnt
'Set the bits back to the picture
SetBitmapBits Picture1.Picture, UBound(PicBits), PicBits(1)
'refresh
Picture1.Refresh
End Sub

liuyan4794 2003-10-25
  • 打赏
  • 举报
回复
怎么没其他人回答啊?
rainstormmaster 2003-10-21
  • 打赏
  • 举报
回复
参考:
http://expert.csdn.net/Expert/topic/1736/1736081.xml?temp=.7990076
hxy2003 2003-10-21
  • 打赏
  • 举报
回复
getcXX

1,485

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧