Using C# and DirectX for fast screen captures...
Code Project - Very fast screen capture using DirectX in C#
"Traditionally screen captures are obtained by GDI, but it's slow. In my homemade ambilight project, I needed a fast printscreen and it's posibble: DirectX device has a front buffer - direct image of the screen.
Introduction
Recently I programmed my new project - homemade ambilight. Ambilight is a backlight behind television. The light is the average of some pixels in the screen. In order to get the colors for the ambilight, I needed fast screen capture. After some search, I heard about the front buffer. DirectX devices have this cool property. It contains the actual screen image. It is faster than GDI. DirectX puts an image in the surface object and it's faster for processing than GDI's bitmap.
Requirements and project preparing
Your project must be
STAThread
. First you need the DirectX SDK. It contains all the libraries that you need. When you have it downloaded and installed, add to your project the following references:
- Microsoft.DirectX
- Microsoft.DirectX.Direct3D
- Microsoft.DirectX.Direct3DX
If you can't find these in the list of references, then look for these libraries in "C:\Windows\Microsoft.NET\DirectX for Managed Code" and "C:\Windows\Microsoft.NET".
In order to get Direct3D working, we have to add these lines into the app.config (if it doesn't exist, add a new file):
...
This is a different from other approaches I 've seen for grabbing screen-shots...
No comments:
Post a Comment