?
Solved

send pictures through the winsock control

Posted on 1998-10-28
11
Medium Priority
?
634 Views
Last Modified: 2013-11-13
I have a server application with a picturebox, this
application is connected to a client application
that also have a picturebox.

I wan't to send .gif pictures between the two application.
I have tried to send them using this line:
winsock1.senddata pic1.picture

but I don't know how to write the DataArrival for it.
If anyone knows how to do it, please answer me.
0
Comment
Question by:otroligafredde
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 12

Expert Comment

by:mark2150
ID: 1442073
Would think you'd have to send it as a *file*. Handle it like any other file attachment.

M
0
 
LVL 1

Expert Comment

by:Chamberlain
ID: 1442074
Unfortunatley, you have no way of doing it strictly in VB then to save it to a file, send the file and on the other side, write the file and open it with load picture.

I've done it in memory by using the LEAD tools.  It has a LoadPictureFromMemory method (or something like that) that allows you to load it from a byte array.  If you use a control that can do that (PictureBox can't) can create a byte array that is large enough to hold the picture and copy the picture into the byte array with memcopy

Declare Sub MemCopy Lib "kernel32" Alias "RtlMoveMemory" (rOvDestination As
Any, rIvSource As Any, ByVal vIlSize As Long)

send the byte array and on the other side, store it in another byte array then use the controls method to load from memory.  I wish I had a better answer for you.

On the flipside, writing temporarily to the disk, opening the file as binary, sending the contents and on the other side writing the contents as is to a new file and then using LoadPicture then delete the files will work and really isn't slow (as compared to the networking)




0
 
LVL 2

Expert Comment

by:peterwest
ID: 1442075
Hmmm, here's an idea - you could cheat!!!

If the following suggestion is acceptable i'll have a look at writing code to achieve it.

1) Use SavePicture command to write the contents of the picturebox to a file.
2) Send the file through the winsock control.
3) At the receiving end capture the picture data and write this to a temporary file.
4) Use the LoadPicture command to load it into the destination picturebox.

There probably is a more elegant way to do it by using API calls - but this is probably the quickest and easiest way to achieve it.  I've not tested this but it should, in theory, work....

Pete

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:peterwest
ID: 1442076
Apologies for posting a reply that someone had already given - I got loads of errors whilst trying to submit my comment and when it finally went through someone had obviouslly beaten me to it!!

Pete

0
 
LVL 2

Expert Comment

by:peterwest
ID: 1442077
Ok then,

I've looked into this and i've now got the code to create the temporary file, trasmit it, receive it at the other end, write it to file and then load it into the box!!! Phew!!

Let me know if you want me to post it.
0
 
LVL 1

Expert Comment

by:Chamberlain
ID: 1442078
I'm sorry peter but you make it sound like it's hard.  It's nothing more than a

SavePicture
Open MyPic as Binary
Get Data

on one side
and on the other side...

Open MyPic as Binary
Put Data
LoadPicture

Then delete the files on each side.

Am I missing something?
0
 
LVL 2

Expert Comment

by:peterwest
ID: 1442079
Chamberlain:

No, you're not missing anything - apart from actually transferring that data through the winsock control - it's NOT hard to do and it only took me about 5 minutes to knock up the code that achieves the aim.

pete
0
 
LVL 3

Author Comment

by:otroligafredde
ID: 1442080
Peter, please send me your solution
to the problem.

0
 
LVL 3

Author Comment

by:otroligafredde
ID: 1442081
Peter:
I have tried to create the temporary file, trasmit it, receive it at the other end, write it to file and then load it into the box. but I just can't get it to work.
I would be grateful if you would post your code.

0
 
LVL 2

Accepted Solution

by:
peterwest earned 400 total points
ID: 1442082
Hi again - apologies for the day,

Right then - i've now written a control which does the following:

1) It works in exactly the same way as a standard winsock control; in fact, it's based on it but extends it's functionality.  It has the following:

    a) An extra property called PictureWindow.  This is just the name of a picture box where any received images will be displayed.
    b) An extra method called SendPicture.  Simple go like this:
             ImageSock1.SendPicture Picture1
       to send the image in picturebox Picture 1.

All of this is totally transparent.  There are two things I can do - bearing in mind the aim of this site is to share knowledge.   I will either

A) Post the entire source code the the control (not my preferred way)
B) If anyone want's to e-mail me their e-mail address at 'peterjwest@yahoo.com'  I will e-mail you both the control and a VB6 program that shows you how to use the control.  As well as sending the control i'll also send the source files as well.

Let me know what you'd like me to do.

Cheers

Pete

0
 
LVL 3

Author Comment

by:otroligafredde
ID: 1442083
Peter:

This sounds exellent!
I'll e-mail my address.
Fredde.

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question