运行代码之后,在picturebox里面用鼠标移动事件画曲线,我想把…
vb.net吧
全部回复
仅看楼主
level 1
glc1314521 楼主
曲线保存成图片格式?可是
这是我写的代码,保存之后只是一张空白图片……而没有我画的曲线啊??帮我看看
Public Class Form1
Dim preX As Single
Dim preY As Single
Private pStart, pEnd As Point
Dim ep As New Pen(Color.Red, 1)
Public image As Bitmap = Nothing
'Dim bm As New Bitmap(500, 500)
'Dim bm = New Bitmap(Me.PictureBox1.Width, Me.PictureBox1.Height, Me.PictureBox1.CreateGraphics)
'Dim g = Graphics.FromImage(bm)
Dim g As Graphics
Private Sub Picturebox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
Me.PictureBox1.Controls.Clear()
image = New Bitmap(Me.PictureBox1.Width, Me.PictureBox1.Height)
Graphics.FromImage(image).Clear(Color.White)
Me.PictureBox1.Image = DirectCast(image.Clone(), Bitmap)
If e.Button = Windows.Forms.MouseButtons.Left Then
pStart.X = e.X
pStart.Y = e.Y
End If
End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
image = New Bitmap(Me.PictureBox1.Width, Me.PictureBox1.Height)
Using gr As Graphics = Graphics.FromImage(image)
Dim g As Graphics = PictureBox1.CreateGraphics()
If e.Button = Windows.Forms.MouseButtons.Left Then
pEnd.X = e.X
pEnd.Y = e.Y
g.DrawLine(ep, pStart, pEnd)
ListBox1.Items.Add(pStart.X & " " & pStart.Y)
pStart = pEnd
End If
End Using
' PictureBox1.Image. = bm
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox1.Image.Save("C:\Users\Administrator\Desktop\123.jpeg")
End Sub
2012年11月08日 10点11分 1
level 4
Public Class Form1
Dim preX As Single
Dim preY As Single
Private pStart, pEnd As Point
Dim ep As New Pen(Color.Red, 1)
Public image As Bitmap = Nothing
Dim g As Graphics Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, PictureBox1.DoubleClick
Me.PictureBox1.Controls.Clear()
image = New Bitmap(Me.PictureBox1.Width, Me.PictureBox1.Height)
Graphics.FromImage(image).Clear(Color.White)
Me.PictureBox1.Image = DirectCast(image.Clone(), Bitmap)
End Sub Private Sub Picturebox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown If e.Button = Windows.Forms.MouseButtons.Left Then
pStart.X = e.X
pStart.Y = e.Y
End If End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If e.Button = Windows.Forms.MouseButtons.Left Then
g = Graphics.FromImage(image)
pEnd.X = e.X
pEnd.Y = e.Y
g.DrawLine(ep, pStart, pEnd)
ListBox1.Items.Add(pStart.X & " " & pStart.Y)
pStart = pEnd
PictureBox1.Image = image
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox1.Image.Save("C:\123.jpeg")
End Sub End Class
2012年11月09日 00点11分 2
level 4
Public Class Form1
Dim preX As Single
Dim preY As Single
Private pStart, pEnd As Point
Dim ep As New Pen(Color.Red, 1)
Public image As Bitmap = Nothing
Dim g As Graphics Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, PictureBox1.DoubleClick
Me.PictureBox1.Controls.Clear()
image = New Bitmap(Me.PictureBox1.Width, Me.PictureBox1.Height)
g = Graphics.FromImage(image)
g.Clear(Color.White)
Me.PictureBox1.Image = image
End Sub Private Sub Picturebox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown If e.Button = Windows.Forms.MouseButtons.Left Then
pStart.X = e.X
pStart.Y = e.Y
End If End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If e.Button = Windows.Forms.MouseButtons.Left Then
pEnd.X = e.X
pEnd.Y = e.Y
g.DrawLine(ep, pStart, pEnd)
ListBox1.Items.Add(pStart.X & " " & pStart.Y)
pStart = pEnd
PictureBox1.Image = image
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox1.Image.Save("C:\123.jpeg")
End Sub End Class
2012年11月09日 00点11分 3
level 1
你在csdn,百度,贴吧都发了。。。。。
2015年05月29日 13点05分 4
level 13

2015年05月29日 22点05分 5
1