Compression and decompression of game assets is a transparent operation to games. You don't need to modify your game to make use of compressed data.
- Compression occurs as part of the content pipeline portion of the build process. It is performed automatically when you select the property in the Content Build page of the Project Designer.
- Decompression occurs automatically when you access the assets through ContentManager.Load.
Compression of game assets is not available for Zune projects. Microsoft has concluded that the small benefit gained by compressing data for Zune is exceeded by the performance requirements of the Zune processor for decompression.
The compression used by XNA Game Studio uses a variant of the LZ family of compression algorithms, which is an efficient, lossless method.
The ratio of compressed data to source data can vary significantly depending on the character of the source data. However, the average compression ratio for most game asset types is around 60 percent.
The automatic compression algorithms will not compress source data that is very small (a file size less than one disk sector), as the performance benefits of compression are typically lost or even made worse by the execution overhead to decompress the data. These assets will be saved in uncompressed format.
Some content types, such as Song Class and SoundEffect Class data, may not benefit from a general lossless compression algorithm. This is especially true if the data is already compressed in a specialized format.
When implementing a custom content importer, compression can be disabled by overriding the method ContentTypeWriter.ShouldCompressContent, which must return false.
If compression is to be permitted, no action is required. The base class definition of ContentTypeWriter.ShouldCompressContent returns true.