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

发表于:2007-06-21来源:作者:点击数: 标签:
下一页 1 2 3 三、演示程序 文后的程序完整的演示了上述各种图像的特殊处理效果, 编程需要在From1窗体中安放两个图形框Picture1 及Picture2, 还有五个命令按钮Command1-Command5,之后把下述代码填入相应的事件中, 运行程序后通过按钮1-4即可演示上述的四

下一页 1 2 3 

     三、演示程序

  文后的程序完整的演示了上述各种图像的特殊处理效果,

编程需要在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

原文转自:http://www.ltesting.net