Icarus_Feng
Icarus_Feng
2017-10-30 16:29

vb.net GDI+、Bitmap相关问题

  • 位图
  • net

Public Class Form1

Dim g As Graphics
Dim mPen As New Pen(Color.Chocolate, 3)
Public MyBitmap As Bitmap

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    MyBitmap = New Bitmap(Me.PictureBox1.Width, Me.PictureBox1.Height)
    g = Graphics.FromImage(MyBitmap)
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    Dim g1 As Graphics = Me.PictureBox1.CreateGraphics
    Me.PictureBox1.Image = MyBitmap
    g1.DrawLine(mPen, 0, 0, 50, 50)
End Sub

End Class

为什么按button后直线不会留在picturebox上,明明顺序是先还原在画线

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答