First of... I searched a bit and didnt find a complete duplicate of my problem. If I overlooked something please tell me.
I build a small application using C# and the Win32 API to take Screenshots of specified Window Handles. I would like to finalize it with an OBS-like GUI around but I´m hitting a hard problem when it comes to games (and Browser with hardware acceleration on).
Every Time I try to grab the Screenshot from an Application like Notepad it works like a charm but when I tried my App using other types of Windows like Valorant, Super Auto Pets it does not work at all and just returns a white image (but with the exact window size of the game).
When I tested the 3rd game Brotato it worked like a charm again.
So I had success with Godot as the underlying Enginge but not with Unity or Unreal (the other two games)
Im honestly lost and dont even know where to start to fix my problem currently im taking desktop screenshots and crop them. But I would love the screenshot to work in the background too. If another window overlaps with the Game now it just messes up the Screenshot.
Thanks in advance and if you want any code examples tell me.
I tried the different handles for the windows.
Like selecting the child windows one by one. screenshot those and see if ANY of them give me some success.
CodePudding user response:
Simple answer is that you require DirectX or any other API which have access to GPU. It looks like Microsoft recommends this approach to use DirectX: https://learn.microsoft.com/en-us/windows/uwp/gaming/directx-and-xaml-interop
duplicate of C# DirectX screen capture
CodePudding user response:
Working on a game that I'd like to do a 'screen ghosting' effect/glitch, where I take a snap of the present scene (aka 'taking a screenshot'), lower the snap's alpha, and place it at a random small amount of offset for a short period of time before I destroy it.this link might hep you about game cheats https://cheatcommands.cc/xcom-2-console-commands-guide/ Unfortunately, Bitmap.snap is incredibly heavily burdensome (135ms!!!) and so it just can't work for real-time purposes.