We have a C# (WPF) application in which we want to take a screenshot of an arbitrary application launched by us (i.e. so we have a reference to the Process we started).
The application may be minimized or behind other windows but we still only want the image of the individual application, not overlapping pixels.
I know the typical P/Invoke solutions using BitBlt or <a href="http://delphi.about.com/od/delphitips2008/qt/print_window.htm" rel="nofollow noreferrer">PrintWindow</a> work most of the time, but those fail (I only get black/transparent pixels) when dealing with an DirectX or OpenGL application that draws directly to the graphics device. I have found this <a href="http://spazzarama.wordpress.com/2009/02/07/screencapture-with-direct3d/" rel="nofollow noreferrer">article</a> on taking a screenshot of a Direct3D app from C#, so I think I have that case covered.
So my question is this:
<ol>
<li>How would I do this for an OpenGL application?</li>
<li>What is the easiest way to determine the appropriate method to use (PW/DX/GL)?</li>
<li>Is there a single universal way of doing this?</li>
</ol>
For #2, am I relegated to inspecting the modules loaded by the executable and seeing if an DirectX or OpenGL DLL/Assembly is loaded?
This only has to run on Windows XP (not cross-platform and not going to Vista/7 anytime soon if ever for this application).
The application may be minimized or behind other windows but we still only want the image of the individual application, not overlapping pixels.
I know the typical P/Invoke solutions using BitBlt or <a href="http://delphi.about.com/od/delphitips2008/qt/print_window.htm" rel="nofollow noreferrer">PrintWindow</a> work most of the time, but those fail (I only get black/transparent pixels) when dealing with an DirectX or OpenGL application that draws directly to the graphics device. I have found this <a href="http://spazzarama.wordpress.com/2009/02/07/screencapture-with-direct3d/" rel="nofollow noreferrer">article</a> on taking a screenshot of a Direct3D app from C#, so I think I have that case covered.
So my question is this:
<ol>
<li>How would I do this for an OpenGL application?</li>
<li>What is the easiest way to determine the appropriate method to use (PW/DX/GL)?</li>
<li>Is there a single universal way of doing this?</li>
</ol>
For #2, am I relegated to inspecting the modules loaded by the executable and seeing if an DirectX or OpenGL DLL/Assembly is loaded?
This only has to run on Windows XP (not cross-platform and not going to Vista/7 anytime soon if ever for this application).