I have a 14x2 spritesheet which has 125 Kb in raw .png. But as soon as I compile that to .xnb, it mutates to 4 MB.

So my question is: Why is that? And how can I fix that?

  • \$\begingroup\$ Different formats, different sizes. Have you tried different source file sizes? What are you compiling into the .xnb? Are you sure it's only that sprite sheet going in? \$\endgroup\$ – MichaelHouse Jun 27 '13 at 15:43
  • \$\begingroup\$ Yes I am pretty sure. I have another spritesheet which has 10 MB in .xnb format. I think these filesize changes originate from spritesheets with a lot of frames. I would even go so far that the .xnb is every frame * original filesize \$\endgroup\$ – IMX Jun 27 '13 at 16:19

I believe images in xnb format are uncompressed so image file size is purely a function of image size and colour depth.

Width * Height * Depth = Size

If your image is 1024px square at 32 bits per pixel, it'll be 4mb in size.


You could try using the DxtCompressed option, in the solution explorer > content project > image file > properties > texture format - change Color to DxtCompressed

  • \$\begingroup\$ So, reducing the bits from 32 to 16 will make the file 50% smaller \$\endgroup\$ – IMX Jun 27 '13 at 16:22
  • 1
    \$\begingroup\$ That is Correct \$\endgroup\$ – gareththegeek Jun 27 '13 at 16:24

The resources compiled in Debug mode generally comes bigger than the original. Try to compile in Release mode and see the size of the file in the Release folder.

  • \$\begingroup\$ I don't belive this is true. Do you have a source? \$\endgroup\$ – ClassicThunder Jun 28 '13 at 16:32
  • \$\begingroup\$ Just test yourself. \$\endgroup\$ – Emir Lima Jun 28 '13 at 17:05
  • \$\begingroup\$ is true.. xnb are optimized in release mode and are smaller \$\endgroup\$ – Blau Jun 28 '13 at 17:16
  • \$\begingroup\$ I just checked it: Filesizes are all the same \$\endgroup\$ – IMX Jun 28 '13 at 21:27
  • \$\begingroup\$ IMX, how are the files you have tested? I have sprite sheets that in Debug mode gets size of 3mb and in Release mode, they change to 100kb. \$\endgroup\$ – Emir Lima Jul 1 '13 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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