INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

"Retrieve" a picture from an Image control?

"Retrieve" a picture from an Image control?

(OP)
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)?

RE: "Retrieve" a picture from an Image control?

The Picture property of an Image control is exactly the same as the Picture property of a PictureBox control. So if you already know how to send the Picture 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 Picture 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 Handle, so that's what is returned when you 'interrogate' it.

And yes, when the Picture 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 Handle contains the bitmap's hBMP (a handle to the bitmap, so pretty much a pointer to where it is in memory)

RE: "Retrieve" a picture from an Image control?

(OP)
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: "Retrieve" a picture from an Image control?

(OP)
Re Handle, image controls don't have a handle property so how can I make use of this?

RE: "Retrieve" a picture from an Image control?

>Sorry but we never did consider this particular question.

You jest. Here (http://www.tek-tips.com/viewthread.cfm?qid=1686785) is just one thread (of several) where we demonstrated just this sort of thing, in that case specifically converting a Picture 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 Picture 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 Picture property, and that has a Handle

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 Handle somehow is the right approach. Indeed, given your description of the issue, I'd hazard a guess that the Handle will be 0)

RE: "Retrieve" a picture from an Image control?

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close