Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
    
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? –  Byte56 Jun 27 '13 at 15:43
    
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 –  IMX Jun 27 '13 at 16:19

2 Answers 2

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

share|improve this answer
    
So, reducing the bits from 32 to 16 will make the file 50% smaller –  IMX Jun 27 '13 at 16:22
1  
That is Correct –  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.

share|improve this answer
    
I don't belive this is true. Do you have a source? –  ClassicThunder Jun 28 '13 at 16:32
    
Just test yourself. –  Emir Lima Jun 28 '13 at 17:05
    
is true.. xnb are optimized in release mode and are smaller –  Blau Jun 28 '13 at 17:16
    
I just checked it: Filesizes are all the same –  IMX Jun 28 '13 at 21:27
    
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. –  Emir Lima Jul 1 '13 at 16:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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