xna 4 taking desktop screenshot - xna-4.0

Am currently working on a new application at work and am needing some help.
Basically I need to take real time screenshots of an application running on the users desktop(not my application) then warp the image using a shade and display the wrapped screenshot at 60 frames a second.
I have a windows form application that does this but I am getting 6 frames a second and when I scale this up to 1600x1600 it drops to 2fps.
So I thought that if I could do this in xna and move as much as possible to the GPU it would speed it up.
So I have googled and googled and cant find any information on how to get a screenshot of a running application in xna other than my xna application.
Thanks for any help.

You can use XNA or additionaly the DWM or GDI+ to get the full desktop. Here are some links which can help you:
Capture screenshot of hidden desktop
Is there a way to take a screenshot of the user's Windows desktop?
C: take screenshot
What is the best way to take screenshots of a Window with C++ in Windows?
Take screen shot in XNA
I think there is no way to get a window screenshot of another application. You can use some pattern detection code to find out where a window is but I do not recommend this.

Related

StartScreenCapturebyWindowId() not excluding overlapping windows for certain programs (Agora Unity)

I am trying to setup individual window sharing for a project in Unity for Windows. The way I'm currently going about doing this is by using EnumWindows(), IsVisableWindow(), and GetWindowText() to create a dictionary of window titles and handles, then calling StartScreeCapturebyWindowId() to share the selected window.
This works relatively well for most process; the window of the process and only the window of the process is streamed. However, for certain programs (like Google Chrome, Discord, and Windows Photos) the captured area is set correctly, but overlapping windows are not culled out.
Does anyone know what could be causing this problem? Is there something wrong with the way I'm grabbing the handles for these windows? Or is there something about starting a screen capture that I am missing?
You certainly did the correct things. However, you also hit the limitation to the Windows part of the SDK. To understand this better, the set of programs are UWP applications. They have different ways to share the visible pixels. Previously version of Agora SDK could not even show the window. Starting from 3.0.1, the SDK uses Rectangle cutting method to get the window display. You may further read the online documentation about that API here.
There isn't much Agora can do for the near term. So you will just need to deal with the user experience (e.g. by warning them) or look at solutions like using Web SDK instead.

Is it possible that WP7.x APP can use full space on 16:9 (720P)device

I have application Using WP7.x SDK. I am not using any Window Phone 8 feature.
My App's XAML Pages are fitting perfectly on WVGA and WXGA but on 720P on top of screen there is some blank space. How can i fix this problem (I don't want to create seprate build for Window Phone 8).Please advise.
Unfortunately, this is not possible. The WP7 apps running on WP8 devices are constrained in a 480x800 container.
To take advantage of the 720p screen, you'll have to build a WP8 version of your app.
At least graphically this is possible. You can handle WP7 XNA inputs and graphics right: look my awnswer here: https://stackoverflow.com/a/23457119/766304
Second thing that you have to do is render your Silverlight / XAML UI with XNA. More information about that from here: http://msdn.microsoft.com/en-us/library/hh221583.aspx
All of that is tested and works well but this will manipulate only rendering and not XAML input side, input fixing could be possible or not. Still difrense between those two aspect ratios is so small that result can be good enought.

Change the phone editor resolution?

How can I change the resolution of the phone representing the code when in xaml view in a project?
The phone serves as a drag and drop for the controls, does it have a setting somewhere to set it's resolution. Windows Phone 8 currently have three resolutions; 800x480, 1280x720 and 1280x768.
I'm aware the emulator can be started up with different resolution, but my situation is that my CPU does not support this, im debugging straight on my Lumia 920 (1280x768).
I've got no clue on how the application looks like in 800x480.
But it is a simple application, a preview would be good enough.
You need to open the Device Window: Design -> Device Window
There under the display section you can select the display size (3 available).
Additionally you can test any other resolution by disabling the 'Chrome' option in the device window and setting d:DesignHeight and d:DesignWidth of your page to the desired resolution.
I had the problem and after much time searching google and stackoverflow, I don't think that it is possible to change the resolution of the designer window. However, maybe this link can help you, it helped me back a while ago when I had that problem:
WP8 Emulator screen size
It refers to the emulator, but explains how the app UI will be scaled to match different device resolutions. Hope it helps!

OpenCV camera stream stopping while in fullscreen mode

I want to have two aplications simultaneously run: one that analyzes image from webcam written using OpenCV (the image is acquired through callback function) and an application that goes into fullscreen mode (let's say a 3D game). The problem is that while the fullscreen mode is launched the webcam image stream is stopping - the frames simply don't turn up, the callback function isn't called. This seems to be an issue with OpenCV - to test that a simple application displaying the image form camera has been prepared.
Why the image stream could be blocked by the fullscreen mode? How to bypass this?
Thanks for any hints.
Your question does not tell if you have tried to search for the problem in the OpenCV community first, so I post this as a hint in case: http://tech.groups.yahoo.com/group/OpenCV/
Also check out the list of issues, maybe its a known bug: https://code.ros.org/trac/opencv/report/1
I'm not an OpenCV expert so this is closer to a suggestion than an answer - but I've experienced similar on my multi-monitor setup using a number of media players on the second monitor and some fullscreen apps ont he first.
In my limited testing, it comes down to what method is used to render the 3d app - DirectX seems to stop media players, OpenGL doesn't.
So it might not be OpenCV which has a problem - it may be what DirectX does to the hardware during a full-screen game.
Actually the behaviour of the OpenCV camera stream is strange. It seems to depend on the native OpenCV window (cvNamedWindow()) that shows the output image form webcam. If the window is on the same screen that went fullscreen the streaming will continue. If the camera window would be placed on another screen, the stream would stop.
Another curious thing is with the screen resolution change. If you change the resolution of the screen and the camera window is not visible (is closed or even minimalized) the image stream would get blocked.
These are just my observations on the topic, maybe it'll be helpful for someone.

Desktop Window Manager capture the whole screen

I was wondering if anyone could give me a starting point of how to capture the entire screen in Windows Vista/7? I know how to do it in previous versions of Windows, but would really like to keep everything in the D3D stack, without resorting to GDI/BltBit calls.
I realize that you can get a live thumbnail of a given window if you have the HWND using the DWM API, but how do you get a "thumbnail" of the entire desktop?
Thanks,
Alex
Unfortunately, the functions to do this are in the dwmapi.dll, and are undocumented. Someone figured out how to do it to get the directx surface of another window in vista, and use this to capture the screen, but those functions don't work on Windows 7.
The best thing you can do is get the thumbnails of individual windows, at least, that's all I've found.

Resources