Results 1 to 5 of 5

Thread: capture and stream..

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2003
    Location
    Sydney
    Posts
    69

    capture and stream..

    hi all

    i'm wondering if it's possible for me to capture certain amount of my screan at an interval, compress it and send it accross a socket?

    kindof like vnc...

    is it possible in vb?

    thanks

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: capture and stream..

    it would not be easy to do, but, as you may have guessed, anything is possible. these programs tend to only send the data that has changed. this makes the job a lot easier, as usually not too much of the screen changes.
    Of course, if you are transferring graphical data, as opposed to text, it is that much harder!

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: capture and stream..

    Capture a part of the screen is easy, sending it across a socket is also fairly simple. Then we come to the compression part... If you capture a part (or all) of the screen VB will store it as an uncompressed bitmap file. You could use some third party tool to compress it to a JPG or GIF before sending it but you probably need to store it as a file on disk first which also takes time.

    Here's a quick example on how to store a part of the screen and show it in a picture box on a form.
    VB Code:
    1. Private Declare Function GetDesktopWindow _
    2.  Lib "user32.dll" () As Long
    3.  
    4. Private Declare Function GetDC _
    5.  Lib "user32.dll" ( _
    6.  ByVal hwnd As Long) As Long
    7.  
    8. Private Declare Function ReleaseDC _
    9.  Lib "user32.dll" ( _
    10.  ByVal hwnd As Long, _
    11.  ByVal hdc As Long) As Long
    12.  
    13. Private Declare Function BitBlt _
    14.  Lib "gdi32.dll" ( _
    15.  ByVal hDestDC As Long, _
    16.  ByVal x As Long, _
    17.  ByVal y As Long, _
    18.  ByVal nWidth As Long, _
    19.  ByVal nHeight As Long, _
    20.  ByVal hSrcDC As Long, _
    21.  ByVal xSrc As Long, _
    22.  ByVal ySrc As Long, _
    23.  ByVal dwRop As Long) As Long
    24.  
    25. Private Sub Form_Load()
    26.     With Picture1
    27.         .ScaleMode = vbPixels 'for easier calculations
    28.         .AutoRedraw = True
    29.     End With
    30. End Sub
    31.  
    32. Private Sub Command1_Click()
    33.     Capture 10, 10
    34. End Sub
    35.  
    36. Private Sub Capture(ByVal x As Long, ByVal y As Long)
    37.     'We capture the screen at position x,y and
    38.     'use the width and height of the picture box
    39.     Dim hDesktopDC As Long, hDesktopWnd As Long
    40.    
    41.     hDesktopWnd = GetDesktopWindow
    42.     hDesktopDC = GetDC(hDesktopWnd)
    43.     With Picture1
    44.         BitBlt .hdc, 0, 0, .ScaleWidth, .ScaleHeight, hDesktopDC, x, y, vbSrcCopy
    45.         .Refresh
    46.     End With
    47.     ReleaseDC hDesktopWnd, hDesktopDC
    48. End Sub
    Cheers,
    Last edited by Joacim Andersson; Feb 11th, 2005 at 01:50 AM.

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: capture and stream..

    it's much easier sending text only.

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: capture and stream..

    Quote Originally Posted by dglienna
    it's much easier sending text only.
    That's true... and that a fish enjoys water is also true

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