How do I scale up a texture 2d

I just need to scale up my pixel art so I can actually see it.

The SpriteBatch.Draw method has an overload where can specify the scale as a Vector2 for the x- and y-axis

Reference: SpriteBatch.Draw Method API

2 Likes

Just some extra information…

// Load the texture
Texture2D texture = Content.Load<Texture2D>("myTexture");

// Create a destination rectangle with the desired size
// Assuming 16:9
Rectangle destinationRectangle = new Rectangle(0, 0, 1920, 
1080);

// Draw the texture using the destination rectangle
spriteBatch.Begin();
spriteBatch.Draw(texture, destinationRectangle, Color.White);
spriteBatch.End();

You can also use a source rectangle to draw only a portion of the texture and scale it at the same time. Here is an example:

// Load the texture
Texture2D texture = Content.Load<Texture2D>("myTexture");

// Create a source rectangle with the desired size
Rectangle sourceRectangle = new Rectangle(0, 0, texture.Width, texture.Height);

// Create a destination rectangle with the desired size
// Assuming ^2 power of two scaling
Rectangle destinationRectangle = new Rectangle(0, 0, 1000, 1000);

// Draw the texture using the source and destination rectangles
spriteBatch.Begin();
spriteBatch.Draw(
texture, 
destinationRectangle, 
sourceRectangle, 
Color.White);
spriteBatch.End();
2 Likes