[DirectX, C#]Capture screenshot
I'm trying to build an app that would take a fulscreen screenshot.
I've done it in Java using Robots, but that is too slow and it doesn't work on top of directX applications (I get desktop snapshot).
The main point of this app is to take a portion of a screen - a 1/4 on the left side, same amount on the right side and return average RGB values for each side.
So I've started porting app to C# with slimDX and there are some problems.
This is the demo I've cooked using Direct3D9:
adapter = direct3d.Adapters.DefaultAdapter;
parameters = new SlimDX.Direct3D9.PresentParameters();
parameters.BackBufferFormat = adapter.CurrentDisplayMode.Format;
parameters.BackBufferHeight = adapter.CurrentDisplayMode.Height;
parameters.BackBufferWidth = adapter.CurrentDisplayMode.Width;
parameters.Multisample = SlimDX.Direct3D9.MultisampleType.None;
parameters.SwapEffect = SlimDX.Direct3D9.SwapEffect.Discard;
parameters.PresentationInterval = SlimDX.Direct3D9.PresentInterval.Default;
parameters.FullScreenRefreshRateInHertz = 0;
device = new Device(direct3d, adapter.Adapter, DeviceType.Hardware, parameters.DeviceWindowHandle, CreateFlags.SoftwareVertexProcessing, parameters);
surface = Surface.CreateOffscreenPlain(device, adapter.CurrentDisplayMode.Width, adapter.CurrentDisplayMode.Height, Format.A8R8G8B8, Pool.SystemMemory);
DataRectangle dr = surface.LockRectangle(LockFlags.None);
DataStream gs = dr.Data
// calculate average RGB for left side
Color rgb_l = avcs(gs, 0, cap_top);
When I run a fulscreen game e.g. Portal - I get captured only desktop (I've tried to save surface to file for preview), same story is with NFS run, which is a DX11 game.
Is there a better approach to this - I'm more new to graphics programming, but as I understand, what I need is inside front buffer.
Also it would be great if it would work on DX9-DX11
|All times are GMT -5. The time now is 11:52 AM.
Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright ©1998 - 2013, nV News.