Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am new to XNA programming and I loaded the background image using ContentManager as a Texture2D object.

The background image which I have is of size 480*320. I have kept the minimum game window size as 640*480. My question is how would i resize the background image to the size of the game window.

Thanks in advance!

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Whatever size the destination rectangle is for any of the top 3 SpriteBatch.Draw functions is how large your image will appear on screen.

So try the below to automatically draw an image full screen.

SpriteBatch.Draw(background_texture, GraphicsDevice.Viewport.Bounds, Color.White);

Note this doesn't actually change the size of you image it just scales it to the specified size when rendered.

share|improve this answer
    
Wow that was a simple thing to do. Thanks a lot :) –  Gamer Mar 8 '12 at 19:11
    
Welcome to the wonderful world of XNA :) –  ClassicThunder Mar 8 '12 at 19:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.