Example #1
0
        private List <Block> UEzlCompressBytes(byte[] input, ZLibNet.CompressionLevel level, uint alignment)
        {
            List <List <byte> > split   = SplitByteArray(input, alignment);
            List <Block>        _return = new List <Block>();

            for (int i = 0; i < split.Count; i++)
            {
                byte[] array  = split[i].ToArray();
                byte[] array2 = UEzlCompress(array, level);
                _return.Add(new Block
                {
                    Size             = array2.Length + 32,
                    Compressed       = true,
                    UncompressedSize = array.Length,
                    Unknown04        = 32u,
                    Unknown08        = 81920u,
                    Unknown0C        = 135200769u,
                    CompressedSize   = array2.Length,
                    Unknown14        = 0u,
                    Unknown18        = 0u,
                    Unknown1C        = 0u,
                    ZBuffer          = array2
                });

                array  = null;
                array2 = null;

                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            return(_return);
        }
Example #2
0
 private byte[] UEzlCompress(byte[] input, ZLibNet.CompressionLevel level)
 {
     byte[] buffer = null;
     using (var data = new MemoryStream())
     {
         var zlib = new ZLibNet.ZLibStream(data, ZLibNet.CompressionMode.Compress, ZLibNet.CompressionLevel.BestCompression);
         zlib.Write(input, 0, input.Length);
         zlib.Flush();
         buffer = data.GetBuffer();
     }
     return(buffer);
 }