Sprite Sheet Packer includes two ways for XNA games to consume the files:
1) Use the XML exporter which saves into the XML Intermediate Format. Add the XML file to your content project and use Content.Load<Dictionary<string, Rectangle>> to load the file as a dictionary mapping the image name to the source rectangle.
2) Use the TXT exporter and read the file in manually. Below is one way to handle reading in this file:
First, add both the outputted PNG and TXT file to your content project. Right click on the TXT file and choose the Properties option. Find the “Build Action” property and set that to None and the “Copy to Output Directory” property to “Copy if Newer”. This
will copy the text file to your outputted folder without trying to build it as content.
Next, we read in the file. Here’s a snippet from the downloadable sample that shows how that can be achieved:
Dictionary<string, Rectangle> spriteSourceRectangles = new Dictionary<string, Rectangle>();
// open a StreamReader to read the index
string path = Path.Combine(StorageContainer.TitleLocation, "Content\\Sprites.txt");
using (StreamReader reader = new StreamReader(path))
// while we're not done reading...
// get a line
string line = reader.ReadLine();
// split at the equals sign
string sides = line.Split('=');
// trim the right side and split based on spaces
string rectParts = sides.Trim().Split(' ');
// create a rectangle from those parts
Rectangle r = new Rectangle(
// add the name and rectangle to the dictionary