CompressBuffer() public static method

public static CompressBuffer ( byte b, System.Stream compressor ) : void
b byte
compressor System.Stream
return void
Exemplo n.º 1
0
        public static byte[] CompressBuffer(byte[] b)
        {
            using MemoryStream ms = new MemoryStream();
            Stream compressor = new GZipStream(ms, CompressionMode.Compress, CompressionLevel.BestCompression);

            ZlibBaseStream.CompressBuffer(b, compressor);
            return(ms.ToArray());
        }
Exemplo n.º 2
0
 public static byte[] CompressBuffer(byte[] b)
 {
     using (MemoryStream memoryStream = new MemoryStream())
     {
         Stream compressor = (Stream) new GZipStream((Stream)memoryStream, CompressionMode.Compress, CompressionLevel.BestCompression);
         ZlibBaseStream.CompressBuffer(b, compressor);
         return(memoryStream.ToArray());
     }
 }
Exemplo n.º 3
0
        /// <summary>
        ///   Compress a byte array into a new byte array using DEFLATE.
        /// </summary>
        ///
        /// <remarks>
        ///   Uncompress it with <see cref="DeflateStream.UncompressBuffer(byte[])"/>.
        /// </remarks>
        ///
        /// <seealso cref="DeflateStream.CompressString(string)">DeflateStream.CompressString(string)</seealso>
        /// <seealso cref="DeflateStream.UncompressBuffer(byte[])">DeflateStream.UncompressBuffer(byte[])</seealso>
        /// <seealso cref="GZipStream.CompressBuffer(byte[])">GZipStream.CompressBuffer(byte[])</seealso>
        /// <seealso cref="ZlibStream.CompressBuffer(byte[])">ZlibStream.CompressBuffer(byte[])</seealso>
        ///
        /// <param name="b">
        ///   A buffer to compress.
        /// </param>
        ///
        /// <returns>The data in compressed form</returns>
        public static byte[] CompressBuffer(byte[] b)
        {
            using (var ms = new System.IO.MemoryStream()) {
                System.IO.Stream compressor =
                    new DeflateStream(ms, CompressionMode.Compress, CompressionLevel.BestCompression);

                ZlibBaseStream.CompressBuffer(b, compressor);
                return(ms.ToArray());
            }
        }
Exemplo n.º 4
0
 public static byte[] CompressBuffer(byte[] b)
 {
     byte[] result;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         Stream compressor = new DeflateStream(memoryStream, CompressionMode.Compress, CompressionLevel.BestCompression);
         ZlibBaseStream.CompressBuffer(b, compressor);
         result = memoryStream.ToArray();
     }
     return(result);
 }