法甲

VB中PaintPicture图形方法的使用(2)

2019-09-11 14:51:23来源:励志吧0次阅读

三、演示程序   文后的程序完整的演示了上述各种图像的特殊处理效果,编程需要在From1窗体中安放两个图形框Picture1 及Picture2, 还有五个命令按钮Command1-Command5,之后把下述代码填入相应的事件中, 运行程序后通过按钮1-4即可演示上述的四种图像处理效果, 按"退出"按钮则结束程序。以上方法及程序在WINDOWS95系统、VB4.0环境下调试通过。

’图像平铺显示

Private Sub Command1_Click()

Dim numm As Integer

Picture1.AutoSize = True

roww = Int(Form1.Width / Picture1.Width) + 1

coll = Int(Form1.Height / Picture1.Height) + 1

For i = 0 To roww

For j = 0 To coll

Form1.PaintPicture Picture1.Picture,j*Picture1.Width,i*Picture1.Height,Picture1.Width,Picture1.Height

numm = numm + 1

Form1.Caption = "使用图像个数:" + Str$(numm)

Next j

Next i

Picture1.Visible = 0

End Sub

’随机图像显示

Private Sub Command2_Click()

Picture1.AutoSize = True

Do

xx = Rnd * Picture2.Width

yy = Rnd * Picture2.Height

Picture2.PaintPicture Picture1.Picture, xx, yy,Picture1.Width,Picture1.Height

DoEvents

Loop

End Sub

[下一页]

’镜头推出效果

Private Sub Command3_Click()

Picture2.Cls

Picture1.AutoSize = False

Picture1.Width = 0

Picture1.Height = 0

For i = 0 To 2000 Step 2

roww = (Picture2.Width - Picture1.Width) / 2 - i / 2

coll = (Picture2.Height - Picture1.Height) / 2 - i / 2

Picture2.PaintPicture Picture1.Picture, roww, coll,Picture1.Width + i, Picture1.Height + i

DoEvents

Next i

For i = 2000 To 0 Step -2

roww = (Picture2.Width - Picture1.Width) / 2 - i / 2

coll = (Picture2.Height - Picture1.Height) / 2 - i / 2

Picture2.PaintPicture Picture1.Picture, roww, coll,Picture1.

Width + i, Picture1.Height + i

DoEvents

Next i

Picture1.AutoSize = True

End Sub

[下一页]

’拖尾效果

Private Sub Command4_Click()

Picture2.Cls

Picture1.AutoSize = False

Picture1.Width = 0

Picture1.Height = 0

For i = 0 To 2000 Step 2

stepp = i / 2

Picture2.PaintPicture Picture1.Picture, stepp, stepp,Picture1.Width + i, Picture1.Height + i

DoEvents

Next i

Picture1.AutoSize = True

End Sub

’结束按钮

Private Sub Command5_Click()

End

End Sub

’准备工作

Private Sub Form_Load()

Picture1.Picture = LoadPicture("d:\windows\256color.bmp")

Command1.Caption = "图像平铺"

Command2.Caption = "随机显示"

Command3.Caption = "镜头伸缩"

Command4.Caption = "拖尾效果"

Command5.Caption = "退出"

End Sub

小葵花芪斛楂颗粒
小孩消化不良吃什么药
宝宝老是消化不良怎么办
糖尿病胃轻瘫腹胀吃什么药
分享到: