title: How do I scale a sprite sheet in XNA?
body: <p>I decided to have a play with XNA for Windows Phone 7, and for my first game, I need to take an image and split it up into square sprites, so the image essentially becomes a sprite sheet. The original image will likely be too large or small for the screen, so I've done the following to work out how to apply a scale such that it fits on the screen, but without any gaps showing (so one dimension may go beyond the screen).</p>
  
  <pre><code>Texture = content.Load&lt;Texture2D&gt;(assetName);
  
  var width = Texture.Bounds.Width;
  var height = Texture.Bounds.Height;
  
  var widthDifference = width - screenWidth;
  var heightDifference = height - screenHeight;
  
  if (widthDifference &lt; 0 || heightDifference &lt; 0)
  {
     if (widthDifference &lt; heightDifference)
        Scale = (float) screenWidth/width;
     else
        Scale = (float) screenHeight/height;
  }
  else
  {
     if (widthDifference &gt; heightDifference)
        Scale = (float) screenWidth/width;
     else
        Scale = (float) screenHeight/height;
  }
  
  if (Scale &lt; 0)
     Scale = Scale*-1;
  </code></pre>
  
  <p>But next I need to generate sprites from this image that fill the screen neatly in a grid. I guess my main question is that when I call my draw method on each sprite, does the scaling apply to the original sprite sheet, or just to the sprite itself after taking its texture from the sprite sheet?</p>
  
  <p>If it's the latter, I'm a little confused about how best to scale the sprite sheet before building my individual sprites. I may end up actually first resizing the image to exactly match the screen dimensions to make life easier, but this seems a little heavy handed.</p>
  
  <p>Any suggestions would be most welcome!</p>