扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:enet 来源:soft6 2008年5月14日
关键字: 图形 PaintPicture VB vb.net Windows
文后的程序完整的演示了上述各种图像的特殊处理效果,编程需要在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
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者