3
\$\begingroup\$

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?

\$\endgroup\$
2
  • \$\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\$
    – House
    Jun 27, 2013 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, 2013 at 16:19

2 Answers 2

3
\$\begingroup\$

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.

Edit

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

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

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.

\$\endgroup\$
6
  • \$\begingroup\$ I don't belive this is true. Do you have a source? \$\endgroup\$ Jun 28, 2013 at 16:32
  • \$\begingroup\$ Just test yourself. \$\endgroup\$
    – Emir Lima
    Jun 28, 2013 at 17:05
  • \$\begingroup\$ is true.. xnb are optimized in release mode and are smaller \$\endgroup\$
    – Blau
    Jun 28, 2013 at 17:16
  • \$\begingroup\$ I just checked it: Filesizes are all the same \$\endgroup\$
    – IMX
    Jun 28, 2013 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, 2013 at 16:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .