在picturebox里面通过鼠标移动事件画好的图(好像不是image)?那小弟我该如何保存成图片格式呢?跪求,纠结好久了这个有关问题!多谢了
在picturebox里面通过鼠标移动事件画好的图(好像不是image)?那我该怎么保存成图片格式呢?????跪求,纠结好久了这个问题!谢谢了
在picturebox里面通过鼠标移动事件画好的图?可以保存成图片格式吗?????
------解决方案--------------------
绘制的时候,通过bitmap绘图
Bitmap bmp = new Bitmap(100, 100);
using(Graphics g = Graphics.FromImage(bmp))
{
.....
......
}
string file = "image.jpg";
bmp.Save(file, System.Drawing.Imaging.ImageFormat.Jpeg);
------解决方案--------------------
这是我写的代码,保存之后只是一张空白图片……而没有我画的曲线啊??帮我看看
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
在picturebox里面通过鼠标移动事件画好的图?可以保存成图片格式吗?????
------解决方案--------------------
绘制的时候,通过bitmap绘图
Bitmap bmp = new Bitmap(100, 100);
using(Graphics g = Graphics.FromImage(bmp))
{
.....
......
}
string file = "image.jpg";
bmp.Save(file, System.Drawing.Imaging.ImageFormat.Jpeg);
------解决方案--------------------
这是我写的代码,保存之后只是一张空白图片……而没有我画的曲线啊??帮我看看
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