Ejemplo n.º 1
0
    // Then the ones with dictionary size
    public static void CompressFileToLZMAFile(string inFile, string outFile, LZMADictionarySize dictSize)
    {
        FileStream input = new FileStream(inFile, FileMode.Open);
        FileStream output = new FileStream(outFile, FileMode.Create);

        Compress(input, output, dictSize);
    }
Ejemplo n.º 2
0
    // Then the ones with dictionary size
    public static void CompressFileToLZMAFile(string inFile, string outFile, LZMADictionarySize dictSize)
    {
        FileStream input  = new FileStream(inFile, FileMode.Open);
        FileStream output = new FileStream(outFile, FileMode.Create);

        Compress(input, output, dictSize);
    }
Ejemplo n.º 3
0
    public static void CompressByteArrayToLZMAFile(byte[] inByteArray, string outFile, LZMADictionarySize dictSize)
    {
        Stream input = new MemoryStream(inByteArray);
        FileStream output = new FileStream(outFile, FileMode.Create);

        Compress(input, output, dictSize);
    }
Ejemplo n.º 4
0
        public static bool Compress(Stream stream_in,
                                    Stream stream_out,
                                    LZMADictionarySize dictionary_size,
                                    uint level,
                                    CompressProgressCallback progress_callback)
        {
            if (level > 9)
            {
                level = 9;
            }

            LowLevel.Compression.LZMA.CompressionCallback compression_callback = (uint processed_data, uint compressed_size) =>
            {
                if (progress_callback != null)
                {
                    progress_callback(new CompressionProgressData((uint)stream_in.Length, processed_data, compressed_size));
                }
            };

            return(LowLevel.Compression.LZMA.Compress(LowLevel.Compression.LZMA.LZMAStandardLayout,
                                                      stream_in,
                                                      stream_out,
                                                      (uint)dictionary_size,
                                                      level,
                                                      compression_callback));
        }
Ejemplo n.º 5
0
    public static byte[] CompressByteArrayToLZMAByteArray(byte[] inByteArray, LZMADictionarySize dictSize)
    {
        Stream       input  = new MemoryStream(inByteArray);
        MemoryStream output = new MemoryStream();

        Compress(input, output, dictSize);
        return(output.ToArray());
    }
Ejemplo n.º 6
0
    public static byte[] CompressByteArrayToLZMAByteArray(byte[] inByteArray, LZMADictionarySize dictSize)
    {
        Stream input = new MemoryStream(inByteArray);
        MemoryStream output = new MemoryStream();

        Compress(input, output, dictSize);
        return output.ToArray();
    }
Ejemplo n.º 7
0
    private static void Compress(Stream inputStream, Stream outputStream, LZMADictionarySize dictSize)
    {
        SevenZip.Compression.LZMA.Encoder coder = new SevenZip.Compression.LZMA.Encoder();
        Int32 dictSize32 = (Int32)dictSize;

        coder.SetCoderProperties(new SevenZip.CoderPropID[] { SevenZip.CoderPropID.DictionarySize }, new object[] { dictSize32 });
        // Write encoder properties to output stream
        coder.WriteCoderProperties(outputStream);

        // Write size of input stream to output stream.
        outputStream.Write(BitConverter.GetBytes(inputStream.Length), 0, 8);

        // Encode
        coder.Code(inputStream, outputStream, inputStream.Length, -1, null);
        outputStream.Flush();
        outputStream.Close();
    }
Ejemplo n.º 8
0
		public static bool Compress(Stream stream_in,
			Stream stream_out,
			LZMADictionarySize dictionary_size,
			uint level,
			CompressProgressCallback progress_callback)
		{
			if (level > 9)
				level = 9;

			LowLevel.Compression.LZMA.CompressionCallback compression_callback = (uint processed_data, uint compressed_size) =>
				{
					if (progress_callback != null)
						progress_callback(new CompressionProgressData((uint)stream_in.Length, processed_data, compressed_size));
				};

			return LowLevel.Compression.LZMA.Compress(LowLevel.Compression.LZMA.LZMAStandardLayout,
				stream_in,
				stream_out,
				(uint)dictionary_size,
				level,
				compression_callback);
		}
Ejemplo n.º 9
0
    public static void CompressByteArrayToLZMAFile(byte[] inByteArray, string outFile, LZMADictionarySize dictSize)
    {
        Stream     input  = new MemoryStream(inByteArray);
        FileStream output = new FileStream(outFile, FileMode.Create);

        Compress(input, output, dictSize);
    }
Ejemplo n.º 10
0
    private static void Compress(Stream inputStream, Stream outputStream, LZMADictionarySize dictSize)
    {
        SevenZip.Compression.LZMA.Encoder coder = new SevenZip.Compression.LZMA.Encoder();
        Int32 dictSize32 = (Int32)dictSize;
        coder.SetCoderProperties (new SevenZip.CoderPropID[] {SevenZip.CoderPropID.DictionarySize}, new object[] {dictSize32});
        // Write encoder properties to output stream
        coder.WriteCoderProperties(outputStream);

        // Write size of input stream to output stream.
        outputStream.Write(BitConverter.GetBytes(inputStream.Length), 0, 8);

        // Encode
        coder.Code(inputStream, outputStream, inputStream.Length, -1, null);
        outputStream.Flush();
        outputStream.Close();
    }