24 篇文章 1 订阅

# VB PaintPicture （第2篇）

## 1.简单的图片的进入效果

Public Declare Function timeGetTime Lib "winmm.dll" () As Long

Public Sub delay(ByVal n As Single)
Dim tm1 As Long, tm2 As Long
tm1 = timeGetTime
Do
tm2 = timeGetTime
If (tm2 - tm1) / 1000 > n Then Exit Do
DoEvents '转让控制权，令程序在忙于执行指令时抽出少许时间让给别的程序
Loop
End Sub


pic2.PaintPicture pic1.Picture, 0, 0, pic2.ScaleWidth, pic2.ScaleHeight, 0, 0, pic1.ScaleWidth, pic1.ScaleHeight


(x1，y1)需要水平右移，即x1增大，y1不变，由上面坐标系的分析可知x1是从-pic2.scalewidth 移动到0

pic2.Cls
For i = -pic2.ScaleWidth To 0 Step 20
pic2.PaintPicture pic1.Picture, i, 0, pic2.ScaleWidth, pic2.ScaleHeight, 0, 0, pic1.ScaleWidth, pic1.ScaleHeight
delay 0.00005
Next i


pic2.Cls
Dim id As Single '比例
Dim j As Single
For i = -pic2.ScaleWidth To 0 Step 20
id = i / pic2.ScaleWidth
j = id * pic2.ScaleHeight
pic2.PaintPicture pic1.Picture, i, j, pic2.ScaleWidth, pic2.ScaleHeight, 0, 0, pic1.ScaleWidth, pic1.ScaleHeight
delay 0.00005
Next i


pic2.Cls
Dim id As Single '比例
Dim j As Single
For i = pic2.ScaleWidth To 0 Step -20
id = i / pic2.ScaleWidth
j = -id * pic2.ScaleHeight ' i 是减小，j是增大
pic2.PaintPicture pic1.Picture, i, j, pic2.ScaleWidth, pic2.ScaleHeight, 0, 0, pic1.ScaleWidth, pic1.ScaleHeight
delay 0.00005
Next i


## 2.百叶窗效果

pic2.Cls
Dim pages As Integer
pages = 20   '切成20个横条
Dim sy As Single   '每个横条的高度
sy = pic1.ScaleHeight / pages
Dim gao, id As Single  'gao表示当前每个横条画出来的高度，id是比例
id = pic2.ScaleHeight / pic1.ScaleHeight
For gao = 20 To sy + 10 Step 2
For i = 0 To pages - 1
pic2.PaintPicture pic1.Picture, 0, sy * i * id, pic2.ScaleWidth, gao * id, 0, sy * i, pic1.ScaleWidth, gao
Next i
delay 0.00002
Next gao


pic2.Cls
Dim pages As Integer
pages = 40  '切成40个纵条
Dim sx As Single '每个纵条的宽度
sx = pic1.ScaleWidth / pages

Dim kuan, id As Single 'kuan表示当前每个纵条画出来的宽度
id = pic2.ScaleWidth / pic1.ScaleWidth
For kuan = 20 To sx + 5 Step 2
For i = 0 To pages - 1
pic2.PaintPicture pic1.Picture, sx * i * id, 0, kuan * id, pic2.ScaleHeight, sx * i, 0, kuan, pic1.ScaleHeight
Next i
delay 0.00002
Next kuan


## 结束

11-18 4061

12-11 1万+
01-24 2413
05-01 1502
12-12 267
11-24 2788

### “相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

Fanstorm丶

¥2 ¥4 ¥6 ¥10 ¥20

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。