caution021
Member
- Joined
 - Dec 16, 2011
 
- Messages
 - 5
 
- Programming Experience
 - Beginner
 
i have here a code that allows me to draw on a picturebox, but my problem is i want it to save on a specific directory for example: "C:\image". how can i do this? thanks in advance
	
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
	
		
			
		
		
	
				
			
			
				VB.NET:
			
		
		
		[/FONT][/COLOR]Imports SystemImports System.Drawing
Imports System.Drawing.Imaging
Imports System.Windows.Forms
Public Class Signature
    Inherits System.Windows.Forms.Form
    Dim mousePath As New System.Drawing.Drawing2D.GraphicsPath()
    Dim myAlpha As Integer = 100
    Dim myUserColor As New Color()
    Dim myPenWidth As Single = 2
    Private clearImage As Boolean
    Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles PictureBox1.MouseDown
        If e.Button = MouseButtons.Left Then
            mousePath.StartFigure()
        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 = MouseButtons.Left Then
            Try
                mousePath.AddLine(e.X, e.Y, e.X, e.Y)
            Catch
                MsgBox("No way, Hose!")
            End Try
        End If
        PictureBox1.Invalidate()
    End Sub
    Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
        If clearImage Then
            clearImage = False
            e.Graphics.Clear(Color.White)
        End If
        Try
            myUserColor = (System.Drawing.Color.Black)
            myAlpha = 255
            Dim CurrentPen = New Pen(Color.FromArgb(myAlpha, myUserColor), myPenWidth) 'Set up the pen
            e.Graphics.DrawPath(CurrentPen, mousePath)  'draw the path! :)
        Catch
            MsgBox("Not happening!")
        End Try
    End Sub
    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        clearImage = True
        PictureBox1.Invalidate()
        mousePath.Reset()
    End Sub
    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        If SaveFileDialog1.ShowDialog = DialogResult.OK Then
            Dim B As New Bitmap(PictureBox1.Width, PictureBox1.Height)
            PictureBox1.DrawToBitmap(B, PictureBox1.Bounds)
            B.Save(SaveFileDialog1.FileName)
            clearImage = True
            PictureBox1.Invalidate()
            mousePath.Reset()
            Me.Close()
        End If
    End Sub
End Class[COLOR=#000000][FONT=verdana]