take screenshot on secondary screen

Started by
11 comments, last by Norman Barrows 8 years, 5 months ago

Hi,

How can I take a screenshot on my secondary screen?

Thats what i have.


public Bitmap CaptureScreen()
        {
            using(Surface s = Surface.CreateOffscreenPlain(d, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, Format.A8R8G8B8, 
            Pool.SystemMemory))
            {
                d.GetFrontBufferData(0, s);
                Bitmap b = new Bitmap(SlimDX.Direct3D9.Surface.ToStream(s, SlimDX.Direct3D9.ImageFileFormat.Bmp, new Rectangle(222, 222, 500, 500)));

                s.Dispose();
                return b;
            }
        }

This works great, but only for my main display.

I could not find anything useful with Google.

Please help me.

Thanks and Greetings

Advertisement

https://msdn.microsoft.com/en-us/library/windows/desktop/bb205431(v=vs.85).aspx

Thanks, but this didnt help...

That's weird because slimDX fully supports Direct3D 9.0c, 9.0 Ex, 10.0, 10.1, 11 which include a function to save a surface directly to file... Perhaps a little more context with your question would be helpful instead of down voting an answer with as much context as your question. It doesn't matter what display you are outputting to, all you need is a surface.

Also I assume you are using multiple swap chains because you are rendering to two different windows. You have to GetFrontBufferData() from the swap chain that is used to draw to your other window.

I can take a screenshot. Its working fine for me. I just dont know how i can take a screenshot from my second desktop.

I tried "Screen.AllScreens" without success.

Would you be able to post a few sections of the pertinent code? like where is 'd' defined? And what methods are you using to draw to the second monitor?

Thats what I have so far:

http://paste.ofcode.org/EfjDzzQ5tJsVZ2mQe7Tnfq

With: Bitmap bitmap = sc.CaptureScreen() I can easily take a screenshot from my main desktop.

I'm still a beginner in programming.

try d.GetFrontBufferData(1, s); instead of d.GetFrontBufferData(0, s);

Also the more of your source you post the more we can help

That's the whole project.

Just want to take a screenshot from my main and secondary display with directx.

After changing to d.GetFrontBufferData(1, s); i got this error:

D3DERR_INVALIDCALL: Invalid call (-2005530516)

Wait are you trying to take a picture of your desktop on your second monitor? As in your not trying to make a game or graphical program?

Also it is not possible for that to be your whole project. It sounds like your level of understanding of programming and software is at a point to where you need to keep teaching your self first by going through the basics before jumping straight into directx. This includes debugging techniques, research techiniques and understanding how to search documentation for a solution to your problem. I want to help you but there is a lack of information to your question.

This topic is closed to new replies.

Advertisement