microsoft / WindowsCompositionSamples

The Windows Composition Samples have moved here: https://github.com/microsoft/WindowsAppSDK-Samples/tree/main/Samples/SceneGraph
https://github.com/microsoft/WindowsAppSDK-Samples/tree/main/Samples/SceneGraph
MIT License
1.12k stars 287 forks source link

Screen capture semi-transparent windows? #334

Closed NickThissen closed 5 years ago

NickThissen commented 5 years ago

Hello,

I'm trying to use the Screen Capture sample to capture a (semi) transparent window. I followed the sample in a new UWP desktop app as described here: https://docs.microsoft.com/en-us/windows/uwp/audio-video-camera/screen-capture

I am able to capture any kind of window, display it in my app in real-time, and store screenshots from it.

Unfortunately, when I try to capture a transparent window, the transparency is black and I cannot find a way to keep the transparency intact.

The window in question is in a WPF application and the window has AllowsTransparency set to true, along with the WS_EX_TRANSPARENT flag.

Is it possible to:

  1. Capture such a transparent window while keeping the transparency intact?
  2. Save a screenshot (PNG) with the transparency intact?
krenner commented 5 years ago

@robmikh

robmikh commented 5 years ago

Closing this as I think this was addressed in https://github.com/microsoft/Windows.UI.Composition-Win32-Samples/issues/41, feel free to reopen this if I'm mistaken.

NickThissen commented 5 years ago

Yes I assume this was not working due to the same bug in W10. However, I have not verified if the latest insider build fixed it in the UWP version, I only verified that the WPF composition version was fixed. But if they're using the same api under the hood I guess this issue is also resolved now.