Hi,
I am currently making a screen sharing program (Kinda like Skype does), I did the networking part and all that and it does works, however it's quite slow, even on localhost, so I found the culprit and it turns out that taking a screenshot takes quite some time (70ms) so it pretty much runs slow because of this.
Here's the current code to take a screenshot :
[CODE]Public Function ScreenCap() As Image
Dim screenSize As Size = New Size(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
Dim screenGrab As New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
Dim g As Graphics = Graphics.FromImage(screenGrab)
g.CopyFromScreen(New Point(0, 0), New Point(0, 0), screenSize)
g.Dispose()
Return screenGrab
End Function
[/CODE]
However it's not fast enough to keep a stable FPS for the screen sharing, is there a faster way to take a screenshot in .NET ? I heard that using DirectX makes it much faster but Google is being confusing as how to use it.
Thanks in advance !
Indeed taking screenshots using standard screenshot functions is not viable for recording video. I'd wager most applications that do the latter indeed use DirectX.
Did you find this tutorial? [url]http://www.codeproject.com/Articles/274461/Very-fast-screen-capture-using-DirectX-in-Csharp[/url]
After a quick look through, I don't find it very confusing myself. However, it might be outdated (I'm not sure whether there are more modern ways of accessing DirectX from .NET).
If the C# syntax confuses you: Please do learn it. C-like languages have a lot more real world value (as in, for projects bigger than a small hobby project) than VB.NET.
-snip-
Using a mirror driver is a very fast way to get Screenshots:
[url]http://www.demoforge.com/dfmirage.htm[/url]
You can find a C# Sample here:
[url]http://www.demoforge.com/sdk/MirrSharp.zip[/url]
[QUOTE=DrTaxi;44441106]Indeed taking screenshots using standard screenshot functions is not viable for recording video. I'd wager most applications that do the latter indeed use DirectX.
Did you find this tutorial? [URL]http://www.codeproject.com/Articles/274461/Very-fast-screen-capture-using-DirectX-in-Csharp[/URL]
After a quick look through, I don't find it very confusing myself. However, it might be outdated (I'm not sure whether there are more modern ways of accessing DirectX from .NET).
If the C# syntax confuses you: Please do learn it. C-like languages have a lot more real world value (as in, for projects bigger than a small hobby project) than VB.NET.[/QUOTE]
Thank you very much, exactly what I needed, also the C# syntax doesn't confuse me, i'm currently learning it with a few Visual Studio 2012 test programs & Unity, it's just that since it's getting a little complex, I prefered to use a syntax that I was more familiar with.
Again, thank you for your help.
[editline]3rd April 2014[/editline]
[QUOTE=eloreda;44441176]Using a mirror driver is a very fast way to get Screenshots:
[URL]http://www.demoforge.com/dfmirage.htm[/URL]
You can find a C# Sample here:
[URL]http://www.demoforge.com/sdk/MirrSharp.zip[/URL][/QUOTE]
Thanks ! But installing a driver seems less lightweight, I prefer doing it with native stuff.
Sorry, you need to Log In to post a reply to this thread.