I'm looking for a fast way to get a bitmap of a given layered WPF window (using a window handle). The window is a semi-transparent WPF window, and the application is running under
Windows XP (not Vista or 7, this is a strong requirement).
I tried quite a few things before looking into DirectX :
- GDI+ : fast but I could not preserve real transparency (can't get rid of the background window/desktop, I want to keep the graphics of the WPF window, nothing else)
- .NET/WPF capturing features (RenderTargetBitmap etc.) : preserve transparency but way too slow
So, I was looking for some kind of fast capture function (~50ms) and I thought maybe DirectX could be a solution. Having no experience at all with DirectX, I tried a couple of things but nothing worked the way I expected :)
The best I could came up was using SlimDX (I'm not a great C++ coder either ;-) ) and modifying some code found online :
using (SlimDX.Direct3D9.Surface surface = device.GetRenderTarget (0))
using (SlimDX.Direct3D9.Surface surface2 = SlimDX.Direct3D9.Surface.
View Complete Post