Hi,
I am currently using the GDI function DrawImage as a substitute for Bitblt in the good old VB6 days (sigh) and as it turns out I cannot copy an image through two pictureboxes! Can someone please tell me what I am doing wrong in the following code: I have three pictureboxes, and the first has an image in it.
I am copying from the first to the second, and then from the second to the first. It copies from the first to the second just fine, but when it tries to copy from the second to the third it gives me an error of "Object reference not set to an instance of an object."
Dimension a graphics object for the two other pictureboxes.
Dim g1 As Graphics = PictureBox2.CreateGraphics
Dim g2 As Graphics = PictureBox3.CreateGraphics
Dimension a temporary rectangle.
Dim tempRect As New Rectangle(0, 0, 50, 50)
Copy from the first box to the second.
g1.DrawImage(PictureBox1.Image, tempRect)
Copy from the second box to the first.
g2.DrawImage(PictureBox2.Image, tempRect)
Thanks in advance,
Solokin1
I am currently using the GDI function DrawImage as a substitute for Bitblt in the good old VB6 days (sigh) and as it turns out I cannot copy an image through two pictureboxes! Can someone please tell me what I am doing wrong in the following code: I have three pictureboxes, and the first has an image in it.
I am copying from the first to the second, and then from the second to the first. It copies from the first to the second just fine, but when it tries to copy from the second to the third it gives me an error of "Object reference not set to an instance of an object."
Dimension a graphics object for the two other pictureboxes.
Dim g1 As Graphics = PictureBox2.CreateGraphics
Dim g2 As Graphics = PictureBox3.CreateGraphics
Dimension a temporary rectangle.
Dim tempRect As New Rectangle(0, 0, 50, 50)
Copy from the first box to the second.
g1.DrawImage(PictureBox1.Image, tempRect)
Copy from the second box to the first.
g2.DrawImage(PictureBox2.Image, tempRect)
Thanks in advance,
Solokin1