Blank Screenshots In Vista and Win7 when gaming
Asked Answered
M

2

1

I noticed another person also requested help on this. I read that post and it seems it wasn't resolved yet. I also tried changing from my code to the code in the "Screen shot in 2 clicks" Post, But implementing that in my code messed around with all my other code for some reason.

At the moment, The screen shots show up perfectly in Win XP. In Vista and Win7 how ever, they show up blank unless the game is played in window mode. I hope someone out there can help us as this is the last step to finishing our program and we cannot finish without this issue fixed.

The C# code I am using for screen shots is below.

Bitmap bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
                                  Screen.PrimaryScreen.Bounds.Height,
                                  PixelFormat.Format32bppArgb);
Graphics gfxScreenshot = Graphics.FromImage(bmpScreenshot);
gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
                             Screen.PrimaryScreen.Bounds.Y,
                             0, 0,
                             Screen.PrimaryScreen.Bounds.Size,
                             CopyPixelOperation.SourceCopy);
Myrna answered 17/9, 2009 at 14:27 Comment(1)
Simar: Don't write 'urgent' in your titles. It triggers an automatic response, for people like me, to auto-close :) Your urgent problem is not our problem; your interesting problem to solve when we see fit, is :)Slurry
P
4

I would guess you are trying to take a screenshot using the normal screen buffer of a hardware accelerated surface. Your Windows XP result is likely a fluke: a unique or non-optimial video configuration (You'll likely get the same results if you try taking a screenshot of a video - a big black, brown or pink rectangle where the video card inserts the accelerated frame buffer).

You would need to either turn down the systems video acceleration (compatiblity mode where everything gets rendered to the software screen buffer) which is a system wide setting, or change your screenshot code to work directly with the graphics API you are using (DirectX, OpenGL) - the code for that is entirely dependent on the API/method you are using for rendering.

Padnag answered 17/9, 2009 at 14:34 Comment(3)
Hi david, Thanks for the reply. Yeah the game is ran in opengl. It works perfectly every time in winxp. Where can i get some info on changing the code to work with opengl ?Myrna
You could read the pixels with glReadPixels, or use the pBuffer extensions to render a copy of your current screen to a memory buffer of your choosing. The first method is easier to add (it reads right off what you've rendered to the screen), while the second method is faster from a CPU perspective, but might be harder to integrate into your existing code (you have to render your frame a second time, only to the pBuffer instead of the screen)Padnag
any documentation to refer please?Antiknock
S
-2

Above answer is completely wrong besides this quote "change your screenshot code to work directly with the graphics API you are using (DirectX, OpenGL) "

That is a fix but hard.

Your problem is the fact that games are rendered on a different surface in vista and win7.

You either need to hook the graphics (DirectX, OpenGL) or you need to try DWM screen capture.

"Screen shot in 2 clicks" for xp took me about 2000 clicks and countless hours searching for the answer. It is not well documented at all (at least the pure .net solution isnt)

Scyphate answered 5/1, 2010 at 19:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.