Jump to content

Has anyone worked with sharpDX before? im looking through the samples but it looks really complicated to me.

 

basically i just want the a really fast way to grab me some pixel color values of the screen and thought about id grab the screenshot and then do my calculations.

GDI is supposed to be slow and it sounds only logical to go lower. idealy i would do all of it directly on the gpu and only return the color value i want but i dont know how to "execute code on a gpu" / looking into cuda again sounds really complicated and if i can id like a packaged solution for getting a bitmap or buffer[].

 

so i saw sharpdx includes directx12 so i thought that might be the best option but going through the samples i really wish there was a simple wrapper function like 

GetImage(int x,int y,int width,int height)

 

does anyone know of a simple / fast way to capture the screen.

 

btw. im trying to do some ambilight for gaming with my apa102 strip

"You know it'll clock down as soon as it hits 40°C, right?" - "Yeah ... but it doesnt hit 40°C ... ever  😄"

 

GPU: MSI GTX1080 Ti Aero @ 2 GHz (watercooled) CPU: Ryzen 5600X (watercooled) RAM: 32GB 3600Mhz Corsair LPX MB: Gigabyte B550i PSU: Corsair SF750 Case: Hyte Revolt 3

 

Link to comment
https://linustechtips.com/topic/1051199-c-screen-capturing-directx-sharpdx/
Share on other sites

Link to post
Share on other sites

31 minutes ago, cluelessgenius said:

Has anyone worked with sharpDX before? im looking through the samples but it looks really complicated to me.

 

basically i just want the a really fast way to grab me some pixel color values of the screen and thought about id grab the screenshot and then do my calculations.

GDI is supposed to be slow and it sounds only logical to go lower. idealy i would do all of it directly on the gpu and only return the color value i want but i dont know how to "execute code on a gpu" / looking into cuda again sounds really complicated and if i can id like a packaged solution for getting a bitmap or buffer[].

 

so i saw sharpdx includes directx12 so i thought that might be the best option but going through the samples i really wish there was a simple wrapper function like 

GetImage(int x,int y,int width,int height)

 

does anyone know of a simple / fast way to capture the screen.

 

btw. im trying to do some ambilight for gaming with my apa102 strip

This is very difficult. DirectX window when maximized are set in a dedicated mode with the video card and you cannot grab information from it. Your screen shot no matter what you do should result in a Transparent or Black image.

 

That being said DDA do sometime works for some DirectX games. DDA stands for Desktop Duplication API. This is the same system that can copy your laptop screen over a monitor while on a docking station. Works well for GDI and some more recent games. Games that do not work will simply show black screen. I have not yet tested that API with OpenGL content. All my use case are 90% GDI and 10% DirectX (no games).

 

Link to post
Share on other sites

thanks for the reply. 

19 minutes ago, Franck said:

This is very difficult. DirectX window when maximized are set in a dedicated mode with the video card and you cannot grab information from it. Your screen shot no matter what you do should result in a Transparent or Black image.

 

i thought thats exactly what sharpDX was supposed to be for?

Quote

 

That being said DDA do sometime works for some DirectX games. DDA stands for Desktop Duplication API. This is the same system that can copy your laptop screen over a monitor while on a docking station. Works well for GDI and some more recent games. Games that do not work will simply show black screen. I have not yet tested that API with OpenGL content. All my use case are 90% GDI and 10% DirectX (no games).

i have heard multiple times now that having the game in "Borderless Windowed Mode" enable you to capture it. but if its at all possible to somehow get it straight from backbuffer or something id rather do that. as im asking here i am still reading up on the whole topic. and if i dont find any easy solution i will eventually end up learning it the hard way. 

 

also i found this 

https://docs.microsoft.com/en-us/windows/uwp/audio-video-camera/screen-capture

which seems to be very similar to what youre talking about and aparently pretty fresh out ? but again indications of dx11 where sharpdx explicitly mentionens dx12 so...idk

"You know it'll clock down as soon as it hits 40°C, right?" - "Yeah ... but it doesnt hit 40°C ... ever  😄"

 

GPU: MSI GTX1080 Ti Aero @ 2 GHz (watercooled) CPU: Ryzen 5600X (watercooled) RAM: 32GB 3600Mhz Corsair LPX MB: Gigabyte B550i PSU: Corsair SF750 Case: Hyte Revolt 3

 

Link to post
Share on other sites

36 minutes ago, cluelessgenius said:

i have heard multiple times now that having the game in "Borderless Windowed Mode" enable you to capture it.

Yes, hence why i specially said it was difficult when maximized. When it's borderless the DirectX call are not dedicated and can be captured without problem as you can have access to the buffer. You can always make borderless windows mode look like full screen so it wouldn't hurt your gaming. Usually games support startup parameters such as "mygame.exe -windowed" to start them in windowed mode. Worst case the generic key to change between fullscreen and window mode is ALT+Enter i use it often in different 3D engine windows

 

In your case it is the easiest option for DirectX games. GDI you simply use the Windows API to get the full screen and i believe it "could" with OpenGL.

 

Forgot one last solution. You can simplify everything and just install OBS and connect to their API which handle pretty much all case scenario (except some games on DOSBox). I have seen C++ code using it not that long ago so i am guessing the files can either directly be referenced in C# or you can interop it very easily.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×