- 生肖
- 猴
- 星座
- 处女座
- 性别
- 男
- 积分
- 680
- 积分
- 1161
- 精华
- 1
- 阅读权限
- 70
- 注册时间
- 2012-5-3
- 最后登录
- 2016-9-22
- 帖子
- 136
- 生肖
- 猴
- 星座
- 处女座
- 性别
- 男
|
本帖最后由 sky_yx 于 2015-12-30 14:21 编辑
以游戏超级男人暂停效果为例 代码如下:
我这里有三个picture stopp1 stopp2 stopp3(里面还有一个image 装载stop!图像)- Private Sub stop1_Click() ' 暂停过程
- stopN = True '暂停为真
- '------------------------------截当前活动屏
- stopp2.Visible = False
- Clipboard.Clear
- keybd_event 18, 0, 0, 0
- keybd_event vbKeySnapshot, 0&, 0&, 0&
- DoEvents
-
- t = Timer
- Do While Timer - t < 0.1
- DoEvents
- Loop
-
- keybd_event 18, 0, KEYEVENTF_KEYUP, 0
- stopp1.Picture = Clipboard.GetData
- stopp1.Move 0, 0, form1.Width, form1.Height
- stopp3.Move 0, 0, form1.Width, form1.Height
- '------------------------------图像变暗
-
- Dim BITMAP As BITMAPINFO
- Dim ImgData() As Byte
- Dim lIndex As Long
-
- With BITMAP
- .bmiHeader.biSize = 40
- End With
-
- If GetDIBits(stopp1.hdc, stopp1.Picture.Handle, 0, 0, 0, BITMAP, DIB_RGB_COLORS) <> 0 Then '获取图像位图数据大小
- ReDim ImgData(BITMAP.bmiHeader.biSizeImage) '重定义数组准备接收位图数据
- If GetDIBits(stopp1.hdc, stopp1.Picture.Handle, 0, BITMAP.bmiHeader.biHeight - 1, ImgData(0), BITMAP, DIB_RGB_COLORS) <> 0 Then '正式获取位图数据并将数据存入定义的数组中
- '注意数组中颜色分量的存储顺序为:B、G、R(并不是R、G、B),如果你需要对图像进行处理只需改变数组中的数据即可完成
-
- '**************** 下面这段程序是将图像亮度变暗(只作为演示,其它效果你可以自己动手做) ***********************
- '注意:第一条扫描线的位置是从左下角开始
-
- For lIndex = 0 To BITMAP.bmiHeader.biSizeImage
- If ImgData(lIndex) - 50 < 0 Then
- ImgData(lIndex) = 0
- Else
- ImgData(lIndex) = ImgData(lIndex) - 50
- End If
- Next
- '*********************************************************************
-
- SetDIBits stopp3.hdc, stopp3.Image.Handle, 0, BITMAP.bmiHeader.biHeight - 1, ImgData(0), BITMAP, DIB_RGB_COLORS '将位图数据写入stopp3中
- End If
- End If
- stopp3.Picture = stopp3.Image
- '====================================剪切stopp3为stopp1
- stopp2.Visible = True
- stopp2.Move 0, 0, form1.ScaleWidth, form1.ScaleHeight
- stopp2.PaintPicture stopp3, (form1.ScaleWidth - form1.Width) / 2, form1.ScaleHeight - form1.Height - (form1.ScaleWidth - form1.Width) / 2, form1.Width, form1.Height, 0, 0, form1.Width, form1.Height
- Image1.Move 200, 200
复制代码 模块:- '-----------------------------------------------------模拟按键
- Public Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
- Public Const KEYEVENTF_KEYUP = &H2 '模拟按键截屏
- '-----------------------------------------------------------------------------像素读取 图像转暗
- Public Declare Function GetDIBits Lib "gdi32" (ByVal aHDC As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As BITMAPINFO, ByVal wUsage As Long) As Long
- Public Declare Function SetDIBits Lib "gdi32" (ByVal hdc As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As BITMAPINFO, ByVal wUsage As Long) As Long
- Public Type BITMAPINFOHEADER '40 bytes
- biSize As Long
- biWidth As Long
- biHeight As Long
- biPlanes As Integer
- biBitCount As Integer
- biCompression As Long
- biSizeImage As Long
- biXPelsPerMeter As Long
- biYPelsPerMeter As Long
- biClrUsed As Long
- biClrImportant As Long
- End Type
- Public Type RGBQUAD
- rgbBlue As Byte
- rgbGreen As Byte
- rgbRed As Byte
- rgbReserved As Byte
- End Type
- bmiHeader As BITMAPINFOHEADER
- bmiColors As RGBQUAD
- End Type
- Public Const DIB_RGB_COLORS = 0 ' color table in RGBs
复制代码 效果图:
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
|