B
booboo_US
Guest
Hi Everyone:
I am using vb.net 2019 and I need to manipulate a picturebox image. Unfortunately, I am extremely new to bitmaps and graphics. I tried to read on it, but I still could not get it. Also, in other posts (for other issues), several persons (Tommytwotrain) had helped me, but still I cannot figure out my problem.So, here is my question/problem.
I have two forms.
On form1, I have a picturebox and a command button. The image of the picturebox is set to the attached image (335 by 288 pixels). When the user clicks on the command button, it will open form2.
On form2, I have two pictureboxes and two command buttons. Initially the two pictureboxes have the same image as for the picturebox in form1. One command button is to draw a line, and the second command button is to reset.
For some reason the code to reset does not work, and I have tried all sort of things.
I appreciate all your help and any code.
Bob
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
bmp = PictureBox1.Image
Form2.ShowDialog()
MsgBox("I am done")
End Sub
End Class
Public Class Form2
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PictureBox2.Image = bmp
PictureBox1.Image = bmp
End Sub
Private Sub BtnDraw_Click(sender As Object, e As EventArgs) Handles BtnDraw.Click
Using g As Graphics = Graphics.FromImage(bmp), p As New Pen(Color.Red, 8)
g.DrawImage(PictureBox2.Image, 0, 0)
g.DrawLine(p, 0, 50, 300, 50)
PictureBox2.Image = bmp
End Using
End Sub
Private Sub BtnReset_Click(sender As Object, e As EventArgs) Handles BtnReset.Click
PictureBox2.Image = PictureBox1.Image
End Sub
End Class
Module Module1
Public bmp As New Bitmap(335, 288)
End Module
Continue reading...
I am using vb.net 2019 and I need to manipulate a picturebox image. Unfortunately, I am extremely new to bitmaps and graphics. I tried to read on it, but I still could not get it. Also, in other posts (for other issues), several persons (Tommytwotrain) had helped me, but still I cannot figure out my problem.So, here is my question/problem.
I have two forms.
On form1, I have a picturebox and a command button. The image of the picturebox is set to the attached image (335 by 288 pixels). When the user clicks on the command button, it will open form2.
On form2, I have two pictureboxes and two command buttons. Initially the two pictureboxes have the same image as for the picturebox in form1. One command button is to draw a line, and the second command button is to reset.
For some reason the code to reset does not work, and I have tried all sort of things.
I appreciate all your help and any code.
Bob
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
bmp = PictureBox1.Image
Form2.ShowDialog()
MsgBox("I am done")
End Sub
End Class
Public Class Form2
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PictureBox2.Image = bmp
PictureBox1.Image = bmp
End Sub
Private Sub BtnDraw_Click(sender As Object, e As EventArgs) Handles BtnDraw.Click
Using g As Graphics = Graphics.FromImage(bmp), p As New Pen(Color.Red, 8)
g.DrawImage(PictureBox2.Image, 0, 0)
g.DrawLine(p, 0, 50, 300, 50)
PictureBox2.Image = bmp
End Using
End Sub
Private Sub BtnReset_Click(sender As Object, e As EventArgs) Handles BtnReset.Click
PictureBox2.Image = PictureBox1.Image
End Sub
End Class
Module Module1
Public bmp As New Bitmap(335, 288)
End Module
Continue reading...