Puzzled: Send hdc data of a picturebox to picture2.picture

Marce22
02-12-2005, 01:47 PM
Alright,
This has puzzled me for well over a week, and I am simply at a loss. I have a picture box (picture1), that has an image in its hdc. Now, I'd like to send this picture in the hdc to another picture box (picture2), so I can then, for example do:

savepicuture picture2.picture, "c:\asdf.bmp"

Now here's where it gets trickier. Picture1, where the hdc is stored, is not visible...

You can see the attached project my attempt to figure this out by clicking on the command button. Please help! :confused:

zelg37
02-13-2005, 03:36 AM
I looked at your project but couldn't really see how it works because I have no camera capture..so are trying to do some kind of webcam capture?

If so you might want to try transfering using the clipboard.
Page with necessary code:
http://tek-tips.com/viewthread.cfm?qid=853019
Page with link to downloadable example:
http://www.vb-helper.com/howto_video_capture.html


But it you want to insist on moving around things using a DC backbuffer, that's fine. The way to move graphics from from one DC to another (once you have the hDCs for both) is to use the Bitblt API (with the vbSrcCopy parameter).

After Bitblt is used to transfer the graphic to the hDC of PictureBox2 (with the Picturebox2's AutoRedraw property set to True) it will be stored in the read-only-at-runtime .Image property of the PictureBox2 control

So then, to save the bitmap to a bmp file on the hard drive use:

SavePicture PictureBox2.Image, "TEST.BMP" ' Save picture to file.

You could make the SavePicture statement (you used above) work by transfering the graphics from the .Image property to the Picture property using:

Picture2.Picture=Picture2.Image

I haven't played around with offscreen capture using SendMessage, though.

Marce22
02-14-2005, 02:09 AM
Hey,
Thanks for your reply. Unfortunately I am very unfamiliar with the methods you have suggested. I know you don't have a webcam, but maybe you could still provide an example of some-sorts?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum