0

I typically have been writing xna games for windows phone 7 and set all my content to a build action of compile, which is default; what I've noticed is that my XAP file is now huge after finishing a new project, it seems to have taken 15MB worth of images and blown them up to 200MB in size. Is there anyway to get the build to be smaller while keeping the images compiled? From what I read it compiles images as basically full bitmaps. What's another direction I can take to resolve this issue, as forcing users to download a 200MB app seems unfair when at most it should only take up 15-20MB.

scape
  • 652
  • 12
  • 27

1 Answers1

1

The XNA Content Pipeline basically stores images as they will be used on the GPU. That is either as an uncompressed bitmap, or DXT compressed (which doesn't compress it by much).

So if your original files were in jpeg format (or, to a lesser extent, png), you will find that your original files are much smaller than the built XNB files.

So the answer is to distribute your original jpeg and png files, and load them with Texture2D.FromStream. Note that this uses more CPU power to convert them into the right format at runtime (although I've heard reports of faster loading in some cases, because there's less data being transferred). Also you'll have to do premultiplied alpha manually yourself (and anything else that the content pipeline is handling for you).

Another thing you might want to look into is turning on compression for your sound effects. By default they are uncompressed. See this answer for details.

For more info, this article looks helpful.

Community
  • 1
  • 1
Andrew Russell
  • 26,924
  • 7
  • 58
  • 104
  • Thanks for the info, I was worried I would have to distribute the images separately. That really seems like a waste and bad design, I'm not sure when or where someone would rather have a full-bitmap of an image so for XNA to do this by default... oh well. Out of curiosity what's your plan now that XNA support is dwindling and will not be available for upcoming devices? I've heard of MonoGame but unfortunately the support for 3D is lacking across platforms. – scape Oct 21 '12 at 11:28
  • 1
    I wrote a comment on my blog post [here](http://andrewrussell.net/2012/10/stick-ninjas-devlog-17/) answering a similar question. Regarding distributing the images - the content pipeline is still highly customisable. You could write a `ContentManager`-derived class to handle the loading for you, allowing you to keep that interface identical. You could even write a content pipeline plugin that packages the jpeg/png data (although it would be easier to just include the files as "None/Copy If Newer" in your game project). It'd be nice if XNA had this built in - but you can't have everything :) – Andrew Russell Oct 21 '12 at 12:17