public void CanCompressWithMode(CompressionMode compressionMode) { var data = GetData(); var compressed = Lzo.Compress(compressionMode, data); compressed.Should().NotBeNull().And.NotBeEquivalentTo(data); }
public void CanCompress() { var data = GetData(); var compressed = Lzo.Compress(data); compressed.Should().NotBeNull().And.NotBeEquivalentTo(data); }
private static void Main() { var sample = Encoding.UTF8.GetBytes("Hello World"); var workMemory = new byte[Lzo.WorkMemorySize]; var compressed = Lzo.Compress(CompressionMode.Lzo1x_999, sample); var decompressed = Lzo.Decompress(compressed); Console.WriteLine("sample: {0}", BitConverter.ToString(sample)); Console.WriteLine("compressed: {0}", BitConverter.ToString(compressed)); Console.WriteLine("decompressed: {0}", BitConverter.ToString(decompressed)); }
/// <exception cref="IOException">An I/O error occurs.</exception> /// <exception cref="ObjectDisposedException">The stream is closed.</exception> /// <exception cref="MissingLzoException"></exception> public void Write(GameBoxWriter w, IDRemap remap = default) { GBX.Remap = remap; if (GBX.Header.CompressionOfBody == GameBoxCompression.Uncompressed) { GBX.Node.Write(w); return; } using var msBody = new MemoryStream(); using var gbxwBody = new GameBoxWriter(msBody, body: this); GBX.Node.Write(gbxwBody, remap); var buffer = msBody.ToArray(); var output = Lzo.Compress(buffer); w.Write((int)msBody.Length); // Uncompressed w.Write(output.Length); // Compressed w.WriteBytes(output); // Compressed body data }