XNA 游戏中的 XAP 文件很大,如何在没有图像的情况下编译资源? [英] XAP file from XNA game is huge, how can I compile resources without images being so big?

查看:21
本文介绍了XNA 游戏中的 XAP 文件很大,如何在没有图像的情况下编译资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常一直在为 Windows Phone 7 编写 xna 游戏,并将我的所有内容设置为编译的构建操作,这是默认设置;我注意到的是,在完成一个新项目后,我的 XAP 文件现在很大,它似乎已经拍摄了 15MB 的图像并将它们放大到 200MB.有没有办法在保持图像编译的同时使构建更小?从我读到的内容来看,它将图像编译为基本上完整的位图.我可以采取的另一个方向来解决这个问题,因为强迫用户下载 200MB 的应用程序似乎不公平,因为它最多只应该占用 15-20MB.

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.

推荐答案

XNA 内容管道基本上存储图像,因为它们将在 GPU 上使用.那要么是未压缩的位图,要么是 DXT 压缩的(不会压缩太多).

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).

因此,如果您的原始文件是 jpeg 格式(或者,在较小程度上,png),您会发现您的原始文件很多 小于构建的 XNB 文件.

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.

所以答案是分发您的原始jpegpng 文件,并使用Texture2D.FromStream 加载它们.请注意,这会在运行时使用更多的 CPU 能力将它们转换为正确的格式(尽管我听说在某些情况下加载更快,因为传输的数据较少).此外,您还必须自己手动进行预乘 alpha(以及内容管道为您处理的任何其他内容).

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.

这篇关于XNA 游戏中的 XAP 文件很大,如何在没有图像的情况下编译资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆