Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Retrieve" a picture from an Image control?

Status
Not open for further replies.

tedsmith

Programmer
Nov 23, 2000
1,762
AU
Is it possible to retrieve a picture that is showing in an image control and send it via a network to another computer's image control. Then image control could be shrunk a bit so I would have to send the full original picture, not just take a screenshot of it.
I presume the long value you get when you interrogate Image1.Picture is the location in memory of the start of the picture stored in bitmap form (or is it something different?)
I can decode a stream at the receiving end OK but how do I get the picture data out of memory and send it in byte form (if this is the correct way to do it)?
 
The [tt]Picture[/tt] property of an Image control is exactly the same as the [tt]Picture[/tt] property of a PictureBox control. So if you already know how to send the [tt]Picture[/tt] of a PictureBox (and I think it is fairr to say we covered this fairly comprehensively over the last few years) then you know how to send the [tt]Picture[/tt] property of an Image control

>I presume the long value you get when you interrogate Image1.Picture

Can I advise you to stop using the default property of control? It's sometimes a useful shortcut, but generally a bad idea (and so removed from VB.NET). The default property of an Image's Picture is [tt]Handle[/tt], so that's what is returned when you 'interrogate' it.

And yes, when the [tt]Picture[/tt] holds a bitmap (and yes, it can hold other things ... by which I don't mean jpegs or gifs etc - those are all converted to bitmaps) then the [tt]Handle[/tt] contains the bitmap's hBMP (a handle to the bitmap, so pretty much a pointer to where it is in memory)

 
Sorry but we never did consider this particular question.
Whether it was picture or image control is not an issue either.
Previous posts covered converting the webcam imageA from the clipboard to jpg then sending on network to another computer, converting the jpg so it could be shown on 16 remote imageB controls on one second computer. There are 16 first computers and imageAs. This all works well.

My new challenge is to take these remote imageBs and send them to a third computer with 16 imageC controls at an even remoter location.
I can do this by relaying the received jpg stream at the middle computer as it is shown on it's imageB and using the same receiving code to display it at the third computer imageC but-
The imageC becomes wiped out by any control temporarily shown over it (such as a notification message frame) -but only at the third computer
The only difference is that the streams in the middle computer are indexed because there are 16 'first' computers whereas there is one stream in the third computer because there is only one 'second' computer and the images are sent in turn on 1 winsock.
Indexing was originally necessary so chunks from 2 images didn't get mixed up if sent almost simultaneously from imageAs.

The reason I asked this new question was to get a better understanding of how a picture was stored in an image control.
This is so I can get access to this image so I could magnify one of the thumbnails on demand without wiping out the thumbnails under the bigger picture.
I shall consider your new advice to try to work out how to use the handle.
 
Re Handle, image controls don't have a handle property so how can I make use of this?
 
>Sorry but we never did consider this particular question.

You jest. Here ( is just one thread (of several) where we demonstrated just this sort of thing, in that case specifically converting a [tt]Picture[/tt] object (from a PictureBox control) into an in-memory jpeg, squirting that into a stream, pushing that over winsock, reading the jpeg from the stream at the receiving end, converting that jpeg back into a [tt]Picture[/tt] object and then displaying that in a PictureBox.

But I didn't really expect you to actually be using much of the code we have provided over the years, so I suppose it doesn't surprise me much that you've forgotten the stuff we covered.

> image controls don't have a handle property
No, they have a [tt]Picture[/tt] property, and that has a [tt]Handle[/tt]

Still like to see the code that paints the Image control - as I suspect that that is where the problem lies.

(and I'm not convinced that using the [tt]Handle[/tt] somehow is the right approach. Indeed, given your description of the issue, I'd hazard a guess that the [tt]Handle[/tt] will be 0)
 
I fixed the problem.
I globally dimmed and indexed the hBitMap variable used in Sub CreatePictureFromGDIImage and set the index to the number of the original ImageA sent by the first computer (also equals the index of the ImageCs) and it works just like Loadpicture.

Subsequent pictures were using the same hBitmap variable and overwriting the previous one (which became 0 as you said after the next read) so indexing it fixed the wiping and enlarging problem problems.

Probably the reason I forgot that example of yours was because it was partially not what I was trying to do in the first place.
I never originally wanted to retrieve the original picture from an image or picture box but directly from a web camera.

I'm nearly 79 years old now and not as fast as I used to be but my old client (a State Government Government) wants me to write another program next month involving GPS info from buses to let them know whether 1000 buses will be late or not and feed this to my original system to modify departure times when they are late. They never let you rest! Oh I wish I was camping outback again in the Aussie desert away from it all.

The overall code has turned out quite small and simple and is 100% reliable now. Ir I accumulate the stream from the chunks using MyStream(ImageIndex).Write Buffer(0),ubound(Buffer)+1 it assembles the multiple images perfectly without any mixup.
I didn't use bytestotal because I also send the original ImageIndex and the Totaldatasize first which is included in bytesTotal.

Thanks again for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top