Search code examples
c#xnasizetexture2dtop-down

In Xna, how do i reduce the size of my textures?


i have a 2d top-down game in Xna that uses a single image as it's 'arena'. The image is uses as a Texture2D, 4096*1050, and only 186kb as a png(the graphic is just a plain placeholder for now). When built, the xnb file is 24 mb. So, the question is, is there any way to significantly reduce the texture size?

Thanks in advance


Solution

  • The XNB file produced by the content pipeline contains decompressed image data, so its size is going to be a simple function of the texture's dimensions and bit depth. If you want the file sizes to be smaller, then either use smaller textures (that is to say, fewer pixels; whether you have 1 texture or 100 is irrelevant if they collectively contain the same number of pixels) or use a texture format that stores less data per pixel. You should be able to change the "Texture Format" option (under the content processor) for each texture to adjust its bit depth.

    I would question whether this is really necessary, however. As pointed out in comments, this really shouldn't be that big of a deal, especially if the asset in question is your game's playing field. Is this a phone game?