Пример #1
0
        /// <summary>
        /// Compresses the data of the passed buffer twice.
        /// </summary>
        /// <param name="buffer">The data to be compressed.</param>
        /// <param name="twice">Compress the data twice.</param>
        /// <param name="optimize">Optimize compression rate (slower).</param>
        /// <returns>The double-compressed data.</returns>
        public static byte[] Compress(byte[] buffer, bool twice, bool optimize)
        {
            buffer = Codec.Compress(buffer, optimize);

            if (twice)
            {
                // NOTE: No need to optimize the second compression,
                // it's quite slow and doesn't really improve the compression rate.
                buffer = Codec.Compress(buffer);
            }

            return(buffer);
        }
Пример #2
0
 /// <summary>
 /// Compresses the data of a passed buffer into a destination buffer,
 /// starting at the offset value.
 /// </summary>
 /// <param name="sourceBuffer">The data to be compressed.</param>
 /// <param name="destinationBuffer">The buffer where the compressed data will be saved.</param>
 /// <param name="offset">Location where the data will be saved.</param>
 public static void Compress(byte[] sourceBuffer, byte[] destinationBuffer, int offset)
 {
     byte[] compBuffer = Codec.Compress(sourceBuffer);
     Buffer.BlockCopy(compBuffer, 0, destinationBuffer, offset, compBuffer.Length);
 }
Пример #3
0
 /// <summary>
 /// Compresses the data of the passed buffer.
 /// </summary>
 /// <param name="buffer">The data to be compressed.</param>
 /// <returns>The compressed data.</returns>
 public static byte[] Compress(byte[] buffer)
 {
     return(Codec.Compress(buffer, false));
 }