المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Taking screenshot from a DX game



C# Programming
08-27-2009, 04:23 PM
Hi
Maybe this is the second or third time I'm asking this question here and other programming platforms, yet I still don't have a satisfacting solution/answer.

I would like to be able to get screenshots from a DX game without any black/blank screenshot or desktop views(game is on foreground but desktop is saved in screenshot).

Currently I am using this code to take screenshots, which works most of the time. On XP if anti-aliasing is enabled in game I sometimes get black screenshots. On Vista I sometimes get black screenshots. On 7 if aero is not disabled I get black screenshots all the time or desktop views.

int screenWidth = Screen.GetBounds(new Point(0, 0)).Width;
int screenHeight = Screen.GetBounds(new Point(0, 0)).Height;
Bitmap bmpScreenShot = new Bitmap(screenWidth, screenHeight);
Graphics gfx = Graphics.FromImage((Image)bmpScreenShot);
gfx.CopyFromScreen(0, 0, 0, 0, new Size(screenWidth, screenHeight));
bmpScreenShot.Save("test.jpg", ImageFormat.Jpeg);

I need to take screenshots without these problems without using SlimDX (and other external libraries needed to be installed). But an external DLL is OK.

Thank you. I hope I can solve this with your help.