|
-
Feb 11th, 2005, 12:49 AM
#1
Thread Starter
Lively Member
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
-
Feb 11th, 2005, 01:00 AM
#2
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!
-
Feb 11th, 2005, 01:16 AM
#3
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:
Private Declare Function GetDesktopWindow _
Lib "user32.dll" () As Long
Private Declare Function GetDC _
Lib "user32.dll" ( _
ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC _
Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByVal hdc As Long) As Long
Private Declare Function BitBlt _
Lib "gdi32.dll" ( _
ByVal hDestDC As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal nWidth As Long, _
ByVal nHeight As Long, _
ByVal hSrcDC As Long, _
ByVal xSrc As Long, _
ByVal ySrc As Long, _
ByVal dwRop As Long) As Long
Private Sub Form_Load()
With Picture1
.ScaleMode = vbPixels 'for easier calculations
.AutoRedraw = True
End With
End Sub
Private Sub Command1_Click()
Capture 10, 10
End Sub
Private Sub Capture(ByVal x As Long, ByVal y As Long)
'We capture the screen at position x,y and
'use the width and height of the picture box
Dim hDesktopDC As Long, hDesktopWnd As Long
hDesktopWnd = GetDesktopWindow
hDesktopDC = GetDC(hDesktopWnd)
With Picture1
BitBlt .hdc, 0, 0, .ScaleWidth, .ScaleHeight, hDesktopDC, x, y, vbSrcCopy
.Refresh
End With
ReleaseDC hDesktopWnd, hDesktopDC
End Sub
Cheers,
Last edited by Joacim Andersson; Feb 11th, 2005 at 01:50 AM.
-
Feb 11th, 2005, 02:40 AM
#4
Re: capture and stream..
it's much easier sending text only.
-
Feb 11th, 2005, 02:52 AM
#5
Re: capture and stream..
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|