1

in my application I'm using Media Foundation to render a video from a webcam. The window with the video is part of application window which I want to screenshot programatically as a whole. Now I'm trying to use classic approach for screenshots (copy a window's dc to a bitmap), but the video window is excluded from the picture.

PS1: When I take a picture of a whole application using a Print Screen button, it works. The video window is included.

PS2: As I understand, the Media Foundation uses Direct3D 11 to render a video.

radimoid
  • 199
  • 1
  • 9

1 Answers1

3

You should be using Desktop Duplication API to capture screenshots. Copying DC is legacy approach rather than classic and it can have video parts excluded for good reasons.

Note that even Desktop Duplication can have parts excluded if player or application explicitly request that content is treated as protected (this is for example the case for DRM-enabled video playback applications or media player for DRM-enabled content).

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • Thank you for your answer. But I'm not clever of it at all. Is there any easy way how to call some "screenshot function" which is called by Windows after you press a PrintScreen key? Do Windows use this Desktop Duplication API? – radimoid Feb 11 '19 at 15:03
  • I am not aware of what Print Screen handler does exactly, and then it is not necessarily the method available to you. Desktop Duplication is known to be working well and then the image can be saved to file using, for example, WIC API (other options are available too since at some point you will hold 32-bit RGB pixels). – Roman R. Feb 11 '19 at 15:42
  • What method of the Desktop Duplication API should be used for just taking picture of one window (or eventuelly whole desktop). All I could find is that I should use AcquireNextFrame method of interface which I am not able to obtain. – radimoid Feb 12 '19 at 10:19
  • `AcquireNextFrame` gets you the image of one monitor, not window and not desktop. The question I linked above gives the hints on API used to obtain the interface with this method. – Roman R. Feb 12 '19 at 11:12