예제 #1
0
        public void CanCompressWithMode(CompressionMode compressionMode)
        {
            var data       = GetData();
            var compressed = Lzo.Compress(compressionMode, data);

            compressed.Should().NotBeNull().And.NotBeEquivalentTo(data);
        }
예제 #2
0
        public void CanCompress()
        {
            var data       = GetData();
            var compressed = Lzo.Compress(data);

            compressed.Should().NotBeNull().And.NotBeEquivalentTo(data);
        }
예제 #3
0
파일: Program.cs 프로젝트: wtfblub/SharpLzo
        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));
        }
예제 #4
0
    /// <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
    }