'I wanted a resultfile with an image ,wherupon a red line was painted,
'but what I got was only the image of the picturebox,
'without te red Line.
'the code-line:
'myPictureBox.Image.Save("c:\Temp\MyPicture.jpg", ImageFormat.Jpeg)
'is wrong,
'What is the right code for this?
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
Dim file_name = "C:\TEMP\test.jpg"
myPictureBox.Image = Image.FromFile(file_name)
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
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)
picDownloaded.Image = Image.FromFile("c:\Temp\MyPicture.jpg")
End Sub
End Class