Results 1 to 17 of 17

Thread: sending a picture trough WINSOCK

  1. #1

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172

    Unhappy sending a picture trough WINSOCK

    ok i want a program to send a screenshot of the desktop to a other computer within my network, i can astablish the connection get the screenshot and can send it.. but at arival it fails to work

    i used this to send the picture :

    VB Code:
    1. Private Sub Command2_Click()
    2.  Winsock1.SendData Picture1.Picture
    3. End Sub


    and to recieve it i use:
    VB Code:
    1. Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    2.  Dim strBuff As String
    3.    Winsock1.GetData strBuff, vbString
    4.    Picture1.Picture = strBuff
    5. End Sub

    but i gives this error : Compile error: Type mismatch
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

  2. #2
    Hyperactive Member ZeroCool's Avatar
    Join Date
    Feb 2002
    Location
    In front of my computer
    Posts
    423

    Wink Just A Thought

    Try Changing the String That Holds The Data To A Variant.
    I Can't Think Of Any Other Type that would work!

  3. #3
    sunnyl
    Guest
    You cannot just use Winsock1.SendData Picture1.Picture.

    Winsock sends out data as strings. The type returned by Picture1.Picture is a stdPicture object.

    To send a picture, the easiest way is to actually send the file which the picture came from. If you don't have the picture file, you'll have to create a byte array from the picture and then paint the byte array straight back onto the other end's picturebox.

    Plenty examples of both methods have been posted on the forums.

  4. #4

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172
    errr ok the As variant thing didn't work...
    and i cant find a forum topic where they really change the picture into A byte array can you tell me how it is done?
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

  5. #5
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    eh, isnt it easier just to save the picture first and they start sending it as a file?!!!

  6. #6

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172
    nope i need to grab the screen of one computer and send it as fast as possible to another computer , saving would only take more time because it must have at least a refresh rate of .5 seconds or something..
    on a 700 + mhz computer this might not be a problem
    but on a 200 mhz computer saving would take up to much memory and time
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

  7. #7
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    When using:
    Winsock1.SendData Picture1.Picture
    you would only send the default property of the picture object, which is its handle. This handle will not be valid on another computer.
    You would need to extract the actual data from the picture. Search the forum for the GetDIBits API function. I am sure you will find some code you could use.

    An alternative to writing your own code, is to use a freeware program like winvnc

  8. #8
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    oh well, how about getting the color of each pixel and sending it one by one (that would probably be slower )

  9. #9
    Addicted Member chander's Avatar
    Join Date
    Nov 2000
    Location
    New Delhi , India
    Posts
    225
    hey sunnyl u wrote tht picture can be converted in to byte array , i want to convert a picture from picture box to byte array .. to send to other PC how i can convert it ???
    Chander
    Email:[email protected]

  10. #10
    Fanatic Member jian2587's Avatar
    Join Date
    Aug 2000
    Location
    I bet u need a fusion powered shuttle to reach my place...
    Posts
    963
    UltimaSnake:
    nope i need to grab the screen of one computer and send it as fast as possible to another computer , saving would only take more time because it must have at least a refresh rate of .5 seconds or something..
    on a 700 + mhz computer this might not be a problem
    but on a 200 mhz computer saving would take up to much memory and time
    Use Video hook dont think dat's possible in VB, though
    ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
    Programming is fun, but only if you're not on a tight deadline
    So I consider all those working engineers sad people

    VB FTP class
    3 page PHP crash course
    Crash Course on DX9 Managed with VB.NET covering basics till terrain creation

  11. #11
    Lively Member
    Join Date
    Jun 2000
    Posts
    80
    Hi,

    hey sunnyl u wrote tht picture can be converted in to byte array , i want to convert a picture from picture box to byte array .. to send to other PC how i can convert it ???
    I'm very interested in this, but I couldn't find any examples how to do this.

    To send a picture, the easiest way is to actually send the file which the picture came from. If you don't have the picture file, you'll have to create a byte array from the picture and then paint the byte array straight back onto the other end's picturebox.

    Plenty examples of both methods have been posted on the forums.
    Does anyone know where I can find an example of this method?

    Thanks for reading,

    Fedor

  12. #12
    Fanatic Member jian2587's Avatar
    Join Date
    Aug 2000
    Location
    I bet u need a fusion powered shuttle to reach my place...
    Posts
    963
    I thought this might be better:
    Record a series of pictures, say, for about a second.
    Put them altogether in a file.
    Send it to another remote pc.
    The remote pc reads the file and display the series of pictures
    continuously while grabbing another file.

    How's that?
    ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
    Programming is fun, but only if you're not on a tight deadline
    So I consider all those working engineers sad people

    VB FTP class
    3 page PHP crash course
    Crash Course on DX9 Managed with VB.NET covering basics till terrain creation

  13. #13
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  14. #14
    New Member
    Join Date
    Feb 2010
    Posts
    6

    Re: sending a picture trough WINSOCK

    Hey , you have to split the file to chunks of ( i think - " 1024 " ) byte in order to send !

  15. #15
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: sending a picture trough WINSOCK

    This is 8 year old thread... I think there is no need of replying to this thread anymore...

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  16. #16
    New Member
    Join Date
    Feb 2010
    Posts
    6

    Re: sending a picture trough WINSOCK

    oooh ,,,out of date ,, why not clean up old stuff ??

  17. #17
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: sending a picture trough WINSOCK

    there will be no cleaning of old stuffs... because, others can search the forum for previously asked questions.... and, if it is cleared, then no use....

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width