In a level editor I’ve made for my XNA game (editor is also in XNA) I’m allowing to scale Texture2D objects.
When the user tries to save the level, I’d like to actually resize the image file on disk so that it doesn’t require scaling in the game.
Is there an easy way to create an image file (PNG preferred) from a scaled Texture2D object?
You can scale your textures by rendering to a render target at the size you want and then saving the render target texture.
This simple example shows how you could do that. Ignore the setup of the GraphicsDevice, that’s just to make a small self-contained example. The interesting bit is creating the render target and drawing the scaled texture. You should reuse the render targets where you can (all images of the same size can reuse a render target).