Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

sorry, i meant to say second to third

 

Sorry, in my description of my code I meant to say it copies from the first to the second, and then from the second to the THIRD.

 

Thanks,

Solokin1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...