Shinju
Member
Hi this one should be (I hope) easy to solve. I'm trying to take a copy of a picture on another picturebox using drawimage, where am I going wrong? (I'm almost certainly doing something silly here.
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
Dim DestRect As Rectangle
Dim SrcRect As Rectangle
DestRect = New Rectangle(20, 20, 50,50)
SrcRect = New Rectangle(30, 30, 50, 50)
e.Graphics.DrawImage(PictureBox2.Image, DestRect, SrcRect, GraphicsUnit.Pixel)
End Sub
Its supposed to take a 50x50 square from picturebox1 at (20,20) and place it on picturebox2 at (30x30) but im getting the error "Value cannot be null. Parameter name: image" and its saying PrictureBox2.image is equal to Nothing.
How come, I am drawing on picturebox2 (with things like drawline, drawrectangle and in the paint event correctly - I hope)
Suggestions?
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
Dim DestRect As Rectangle
Dim SrcRect As Rectangle
DestRect = New Rectangle(20, 20, 50,50)
SrcRect = New Rectangle(30, 30, 50, 50)
e.Graphics.DrawImage(PictureBox2.Image, DestRect, SrcRect, GraphicsUnit.Pixel)
End Sub
Its supposed to take a 50x50 square from picturebox1 at (20,20) and place it on picturebox2 at (30x30) but im getting the error "Value cannot be null. Parameter name: image" and its saying PrictureBox2.image is equal to Nothing.
How come, I am drawing on picturebox2 (with things like drawline, drawrectangle and in the paint event correctly - I hope)
Suggestions?