十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
拖一个PictureBox1控件
成都创新互联公司主营夏邑网站建设的网络公司,主营网站建设方案,app软件定制开发,夏邑h5小程序设计搭建,夏邑网站营销推广欢迎夏邑等地区企业咨询
创建一个Paint事件。在事件中加入
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
' Create pens.
Dim redPen As New Pen(Color.Red, 3)
Dim greenPen As New Pen(Color.Green, 3)
' Create points that define curve.
Dim point1 As New Point(50, 50)
Dim point2 As New Point(100, 25)
Dim point3 As New Point(200, 5)
Dim point4 As New Point(250, 50)
Dim point5 As New Point(300, 100)
Dim point6 As New Point(350, 200)
Dim point7 As New Point(250, 250)
Dim curvePoints As Point() = {point1, point2, point3, point4, _
point5, point6, point7}
' Draw lines between original points to screen.
e.Graphics.DrawLines(redPen, curvePoints)
' Draw curve to screen.
e.Graphics.DrawCurve(greenPen, curvePoints)
End Sub
得到数据后,改point的数据。然后PictureBox1.Refresh()就行了
GDI绘图用字体必须安装才能使用
在客户机部署应用程序时,安装该字体就行
如果是简单的移动,先把图形绘制到大小和PictureBox的Bitmap上,然后再绘制到PictureBox就行。
不过在VB.NET中用GDI绘制最好用BufferedGraphics图形缓冲区,速度马马虎虎(VB就这样了),但是不闪烁,不存在背景擦除的问题。
绘图代码写在Paint事件中,如
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim g As Graphics = Me.CreateGraphics
g.DrawLine(Pens.Red, 100, 100, 200, 100)
End Sub
'方法二:在 PictureBox1上显示图像----图画在Bitmap
PictureBox1.Image = Nothing
Dim wid As Integer = PictureBox1.ClientSize.Width
Dim hgt As Integer = PictureBox1.ClientSize.Height
Dim bm As New Bitmap(wid, hgt)
Dim g As Graphics = Graphics.FromImage(bm)
'画图代码
'画图代码
PictureBox1.Image = bm
PictureBox1.Refresh()
g.Dispose()
当然是全部重画。
层只不过是制图软件弄出来的一个方便的东西而已。
就像你画画,画上去如果你要擦掉当然是擦到底色咯。(当然GDI+也可以像你画画一样只擦一部分)
GDI+时钟我写过一个VB6的。代码详见我博客。地址显然百度不让贴上= =。所以你可以看下我的资料。
你可以模拟层,就是把所有绘制信息都保存起来。你的流程应当是:
如果要绘制了,更新绘制信息(可以是数组啥的。),交给一个Draw过程
Draw过程:根据绘制信息,全部绘制。
By vIstaswx ,before junior school graduation exam.