中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 编程语言 > Visual Basic > 综合文章
VB中PaintPicture图形方法的使用(2)
作者:未知 时间:2004-02-14 12:12 出处:eNet硅谷动力 责编:chinaitpower
              摘要:VB中PaintPicture图形方法的使用(2)
  三、演示程序

  文后的程序完整的演示了上述各种图像的特殊处理效果,编程需要在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
关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有