Decompress() public static method

Assigns a decompressed version of InputByteArray to OutputByteArray
public static Decompress ( byte InputByteArray, byte OutputByteArray ) : void
InputByteArray byte The byte array that is to be decompressed
OutputByteArray byte The byte array into which the decompressed data /// is to be written. This array must be allocated before calling the method, and /// it must have exactly the length that is needed to contain the decompressed data. /// If the decompressed data is found to be any larger or smaller than the length of /// OutputByteArray, then this method throws an exception.
return void
コード例 #1
0
        /// <summary>
        /// This method returns an uncompressed version of the given compressed byte array
        /// </summary>
        /// <param name="inputBlob">the byte array to be decompressed</param>
        /// <param name="decompressedLength">the known length of the decompressed byte array</param>
        /// <param name="compressionCode">a generation number that indicates what compression technique to use</param>
        /// <returns>the decompressed byte array</returns>
        public static unsafe Byte[] DecompressBlob(Byte[] inputBlob, int decompressedLength,
                                                   int compressionCode)
        {
            if (compressionCode == 1)
            {
                // the byte array of the output blob
                Byte[] decompressedBlob = new Byte[decompressedLength];
                // Decompress using LZFX algorithm.
                // This method will throw an exception if the decompressed data does not
                // exactly fit into the allocated array size.
                LZFX.Decompress(inputBlob, decompressedBlob);

                return(decompressedBlob);
            }
            if (compressionCode == 2)
            {
                // the byte array of the output blob
                Byte[] decompressedBlob = new Byte[decompressedLength];
                // Decompress using LZFX algorithm.
                // This method will throw an exception if the decompressed data does not
                // exactly fit into the allocated array size.
                LZ4.Decompress(inputBlob, decompressedBlob);

                return(decompressedBlob);
            }
            else
            {   // return without doing any compression
                return(inputBlob);
            }
        }