In VB 2010:
How do i save a drawing on a picturebox to a file on harddisk
Imports System.Drawing.Imaging
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
myPictureBox.BackColor = Color.Yellow
myPictureBox.Image = Image.FromFile("C:\TEMP\test.jpg")
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
myPictureBox.Image.Save("c:\Temp\MyPicture.jpg", ImageFormat.Jpeg)
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim redPen As Pen = New Pen(Color.Red, 20)
Dim point1 As Point = New Point(0, 0)
Dim point2 As Point = New Point(130, 150)
Dim G As Graphics
G = myPictureBox.CreateGraphics
G.DrawLine(redPen, point1, point2)
End Sub
End Class
the save command ( Button1) did not work.
I got the mesage:
Use the New keyword to create the instance.
when I load an image in myPictureBox,
as I now did in the line:
myPictureBox.Image = Image.FromFile("C:\TEMP\test.jpg")
The Save command worked,but the result is not what I want.
I wanted the redline ON my image.
(What I am trying to do is making a program for a child to give color on an loaded bitmap,
and the possebility to store the colored bitmap)
[Edit - Added code block]