Links of Interest
Main
Download
Prerequisites
Screenshots

Articles/Code Snippets
DBP Warmup Entries
Blog feed icon
Contact/Feedback

Quick Downloads:
bullet Diaspora
bullet XNA Requirements Installer

External Links
Heather [layout designer]
XNA

Screenshot Component
class ScreenshotComponent : GameComponent
    {
        public ScreenshotComponent(Game game)
            : base(game)
        {
            KeyboardHelper.OnKeyPressed += new KeyboardHelper.KeyEventHandler(KeyboardHelper_OnKeyPressed);
        }

        void KeyboardHelper_OnKeyPressed(Keys key)
        {
            if (key == Keys.F12)
                TakeScreenshot();
        }

        void TakeScreenshot()
        {
            // Get the graphics device service
            IGraphicsDeviceService graphicsDeviceService = (IGraphicsDeviceService)Game.Services.GetService(typeof(IGraphicsDeviceService));

            // Prepare a texture to save the screenshot into
            Texture2D ss = new Texture2D(graphicsDeviceService.GraphicsDevice, graphicsDeviceService.GraphicsDevice.DisplayMode.Width, graphicsDeviceService.GraphicsDevice.DisplayMode.Height, 1, ResourceUsage.ResolveTarget, graphicsDeviceService.GraphicsDevice.DisplayMode.Format, ResourceManagementMode.Manual);

            // Resolve the back buffer into the screenshot
            graphicsDeviceService.GraphicsDevice.ResolveBackBuffer(ss);

            // Find the next unused screenshot file in the format ssxxx.jpg, where xxx is a three digit number
            DirectoryInfo dir = new DirectoryInfo(Directory.GetCurrentDirectory());
            if (dir.GetDirectories("ss").Length > 0)
                dir = dir.GetDirectories("ss")[0];
            else
                dir = Directory.CreateDirectory("ss");
            FileInfo[] files = dir.GetFiles("ss*.jpg", SearchOption.TopDirectoryOnly);
            int highestSS = 1;
            if (files.Length > 0)
            {
                string[] splits = files[files.Length - 1].Name.Split(new string[] { "ss", "." }, StringSplitOptions.RemoveEmptyEntries);
                highestSS = int.Parse(splits[0]);
            }
            highestSS++;

            // save the screenshot in the format ssxxx.jpg where xxx is a three digit number
            if (highestSS < 10)
                ss.Save("ss\\ss00" + highestSS + ".jpg", ImageFileFormat.Jpg);
            else if (highestSS < 100)
                ss.Save("ss\\ss0" + highestSS + ".jpg", ImageFileFormat.Jpg);
            else
                ss.Save("ss\\ss" + highestSS + ".jpg", ImageFileFormat.Jpg);

            // dispose the screenshot texture
            ss.Dispose();
        }
    }

This website and its content are the property of ascii reversal of the ascii of the hex reversal of the hex of the bit inverse of 11001111 11001111 11001000 11001010 11000110 11001001 10111100 11001001 10111100 11001001 11000110 11001001 11001110 11001001 10111011 11001001 11001111 11001101 10111100 11001011 11000110 11001001.