Game Development Reference
In-Depth Information
internal static TestObject DecompressTestObject(byte[] input)
{
try
{
using (MemoryStream output = new MemoryStream(input))
{
using (GZipStream zipStream = new GZipStream(output,
CompressionMode.Decompress))
{
BinaryFormatter formatter = new BinaryFormatter();
return (formatter.Deserialize(zipStream) as TestObject);
}
}
}
catch (Exception)
{
return null;
}
}
Conclusion
This chapter briefly covered part of data compression theory, though barely
scratching the surface of a complex topic, and then later jumped into implemen-
tation details for the GZipStream class introduced in .NET 2.0.
Data compression has been and always will be a crucial element of many tools,
especially with the projected increase in the volume of game content over the next
couple of years. Data compression also has its place with network tools where
bandwidth and transfer speed is limited.
Search Nedrilad ::




Custom Search