screenshot help!

v8maro

New member
Joined
Feb 24, 2009
Messages
3
Hey guys, im a total newb to d3d, but Im hoping what I am asking is fairly simple.

I have a c# application, I have referenced the required DirectX dlls.

I now have a video game running, in D3D.

I want the c# application to take a screen shot of what I see in-game.

This is what I have so far, and Im kind of lost. Can anyone help me?


IntPtr hWnd = new IntPtr();

foreach (AdapterInformation adapter in Manager.Adapters)
{
// Check whether or not this is the default adapter
if (adapter.Equals(Manager.Adapters.Default))
{
hWnd = Manager.GetAdapterMonitor(adapter.Adapter);
}
}

if (hWnd != null)
{
Device device = new Device(hWnd);

try
{
Surface renderTarget = device.GetBackBuffer(0, 0, BackBufferType.Mono);
SurfaceLoader.SaveToStream(ImageFileFormat.Jpg, renderTarget);
}
catch (AccessViolationException avex)
{
avex.Data.Clear();
}
}



My code is obviously flawed, however, Im not good with this d3d stuff. I realize I am CREATING a new device, which I do not want to do. How do I access the existing application(game) device, and then take a screen shot of it?

Thanks!

Steve
 
Last edited by a moderator:
Back
Top