I was wondering what is the best way to draw textures (for performance). Using the sourceRectange in the spriteBatch.Draw() call and just draw the whole spriteSheet, or crop out every texture on the spritesheet and store them in there own Texture2D object? Like this :
public static Texture2D Crop(Texture2D spriteSheet, Rectangle source)
{
Texture2D croppedTexture2d = new Texture2D(spriteSheet.GraphicsDevice, source.Width, source.Height);
Color[] imageData = new Color[spriteSheet.Width * spriteSheet.Height];
Color[] croppedImageData = new Color[source.Width * source.Height];
spriteSheet.GetData<Color> (imageData);
int index = 0;
for (int y = source.Y; y < source.Y + source.Height; y++)
{
for (int x = source.X; x < source.X + source.Width; x++)
{
croppedImageData [index] = imageData [y * spriteSheet.Width + x];
index++;
}
}
croppedTexture2d.SetData<Color> (croppedImageData);
return croppedTexture2d;
}
And just call that method in the LoadContent() method?