I'm making a small pogram to make memorials in photos is a label and a picturebox how can I record the label along with the image box image for a single image? This is my code.
Imports System.Diagnostics
Imports System.Drawing
Public Class Form1
Dim PPoint As Point
Dim image As Image
Dim graphics As Graphics
Dim fontx As Font
Dim point As PointF
Dim color
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
txtValueX.Text = e.x.tostring
txtValueY.Text = e.Y.ToString
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim OpenFileDialog1 As New OpenFileDialog
OpenFileDialog1.InitialDirectory = "C:\"
OpenFileDialog1.FileName = "Open A File..."
OpenFileDialog1.Multiselect = False
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim sName As String = OpenFileDialog1.SafeFileName
Dim img As String = OpenFileDialog1.FileName
PictureBox1.Image = System.Drawing.Bitmap.FromFile(img)
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
End If
' Load image
image = Drawing.Image.FromFile(OpenFileDialog1.FileName)
graphics = Drawing.Graphics.FromImage(image)
' Create font
fontx = New Font("Times New Roman", 42.0F)
' Create text position
point = New PointF(txtValueX.Text, txtValueY.Text)
' Draw text
graphics.DrawString(TextBox2.Text, fontx, Brushes.Red, point)
End Sub
Private Sub mouseMove_Capture(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles _
MyBase.MouseMove
Dim mousePos As Point = Control.MousePosition
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim OpenFileDialog1 As New OpenFileDialog
OpenFileDialog1.InitialDirectory = "C:\"
OpenFileDialog1.FileName = "Open A File..."
OpenFileDialog1.Multiselect = False
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim sName As String = OpenFileDialog1.SafeFileName
Dim img As String = OpenFileDialog1.FileName
PictureBox1.Image = System.Drawing.Bitmap.FromFile(img)
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
End If
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Label5.Parent = PictureBox1
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
'// Save The image in PictureBox in its Original size.
If Me.PictureBox1.Image IsNot Nothing Then
Me.PictureBox1.Image.Save(IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.MyPictures, "TestFile.jpg"))
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Process.Start("1.jpg")
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
End Sub
Private Sub PictureBox1_MouseClick(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseClick
PPoint = New Point(e.X, e.Y)
Label5.Location = New Point(e.X, e.Y)
End Sub
Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
Label5.Text = TextBox2.Text
Label5.TextAlign = ContentAlignment.MiddleLeft
Label5.Font = New Font("Comic Sans MS", 12, _
FontStyle.Bold Or FontStyle.Underline)
End Sub
Private Sub TrackBar1_Scroll(sender As Object, e As EventArgs) Handles TrackBar1.Scroll
Label5.Font = New Font("Comic Sans MS", TrackBar1.Value, _
FontStyle.Bold Or FontStyle.Underline)
End Sub
Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
FontDialog1.ShowDialog()
Label5.Font = FontDialog1.Font
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
ColorDialog1.ShowDialog()
Label5.ForeColor = ColorDialog1.Color
End Sub
End Class