Exemple #1
0
        /// <summary>
        /// Sets the quality for compression.
        /// </summary>
        /// <param name="quality">The quality value (a value from 0-11).</param>
        public void SetQuality(int quality) {
            if (_mode != CompressionMode.Compress)
                throw new InvalidOperationException("SetQuality is only valid for compress");

            if (quality < Brotli.BROTLI_MIN_QUALITY || quality > Brotli.BROTLI_MAX_QUALITY)
                throw new ArgumentOutOfRangeException(nameof(quality), "Quality should be a value between " +
                                                                       Brotli.BROTLI_MIN_QUALITY + "-" + Brotli
                                                                           .BROTLI_MAX_QUALITY);

            EnsureNotDisposed();

            Brotli.BrotliEncoderSetParameter(ref _encoderState, Brotli.BrotliEncoderParameter.BROTLI_PARAM_QUALITY,
                (uint) quality);
        }
Exemple #2
0
        /// <summary>
        /// Sets the window size for the encoder
        /// </summary>
        /// <param name="windowSize">The window size in bits (a value from 10-24)</param>
        public void SetWindow(int windowSize) {
            if (_mode != CompressionMode.Compress)
                throw new InvalidOperationException("SetWindow is only valid for compress");

            if (windowSize < Brotli.BROTLI_MIN_WINDOW_BITS || windowSize > Brotli.BROTLI_MAX_WINDOW_BITS)
                throw new ArgumentOutOfRangeException(nameof(windowSize), "Window size should be a value between " +
                                                                          Brotli.BROTLI_MIN_WINDOW_BITS + "-" + Brotli
                                                                              .BROTLI_MAX_WINDOW_BITS);

            EnsureNotDisposed();

            Brotli.BrotliEncoderSetParameter(ref _encoderState, Brotli.BrotliEncoderParameter.BROTLI_PARAM_LGWIN,
                (uint) windowSize);
        }