Capturing screenshots from Xbox XNA games

Taking screenshots of Windows games is easy thanks to that handy little PrintScreen key, but Xbox has no built in screenshot functionality so we have to roll our own as part of our game code.

XNA doesn't have any way of transferring files back from Xbox to the development PC, but it does provide the ability to print out information using the System.Diagnostics.Trace API. Printing out an entire screenshot in text format isn't exactly fast, and this solution is certainly a bit of a hack, but it works quite well in practice!

To print out a screenshot from an Xbox game, call this code from very end of your Draw method:

It would be a good idea to hook this up to a spare controller button so you can trigger a screenshot whenever you like while playing the game. Open up the Output window in C# Express, launch your game in the debugger by pressing F5, and watch the pretty numbers appear each time you take a screenshot.

Note how each line of screenshot data is prefixed with the characters "ss". This makes it possible to gracefully ignore any other unrelated printout, and also to properly handle multiple screenshots, so you can print out as many as you like in a single debug session.

When you are done, press ctrl+A to select the entire contents of the output window, then ctrl+C to copy it to the clipboard. C# Express will warn this is a lot of data, which is indeed true, but that's ok.

Now we need a Windows program to reassemble the printout into some more useful format. I wrote a little utility that converts text data from the clipboard into TGA files on disk. For some unknown reason the Clipboard.GetText method didn't work when I tried to compile this as a console application, so in the end I started with a default Windows Application project and added this code to my Form1 constructor:

Hi there. Assuming that I want to keep the file on the xbox hard drive, is there a way to save the image file somewhere. Also since networking is allowed in beta 2 has there been any progress on streaming the images back to a pc.

Shawn Hargreaves goes through the process of getting a scrren shot of you XNA Application on the Xbox 360. The solution uses some different methods to perform the task, remember that there is no way to get content from the Xbox 360 in the traditional