Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ DirectX Capture
I can only capture the desktop by the function GetFrontBufferData()
Is there any way to capture a window?
Posted 28-Mar-13 23:35pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

No, there is no general solution to this via DirectX.
 
The reason for this is that the Window you're trying to capture may have no existance in DirectX at all. If it belongs to an application that doesn't use DirectX then from the DirectX point of view there is nothing special about that area of the screen you see as a window you want to capture, from the point of view of DirectX it's just some pixels in a larger area of pixels without any boundary or associated object.
 
Here are some ideas for potential work arounds:
 
You're better off going via the OS window manager at least to work out initially which pixels are part of the capture area and which aren't. Unfortunately there's no one simple general solution to this either. On WinXP you can use Win32 API, on Vista it's likely broken/missing but should be avalable through Desktop Window Manager as it is on Windows7. On Windows 8 apparently DWM is gone but I can't confirm.
 
An approach that might use DirectX or OpenCV is to get the area of the screen buffer you're interested in from the Graphics hardware. However you're still going to need probably Win32 APIs like GetWindowPos to work out what to capture.
 
It might in the end be easier to capture the whole screen and then duplicate only the part you're interested in and throw the original capture away. Inefficient but possibly easier than trying to get the system to do it for you.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Kornfeld Eliyahu Peter 275
1 Maciej Los 204
2 Sergey Alexandrovich Kryukov 200
3 King Fisher 185
4 OriginalGriff 183
0 OriginalGriff 6,223
1 DamithSL 4,724
2 Maciej Los 4,196
3 Kornfeld Eliyahu Peter 3,894
4 Sergey Alexandrovich Kryukov 3,496


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 29 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100