当前位置: 首页>>代码示例>>C#>>正文


C# CompressionStrategy类代码示例

本文整理汇总了C#中CompressionStrategy的典型用法代码示例。如果您正苦于以下问题:C# CompressionStrategy类的具体用法?C# CompressionStrategy怎么用?C# CompressionStrategy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CompressionStrategy类属于命名空间,在下文中一共展示了CompressionStrategy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WorkItem

        public WorkItem(int size, CompressionLevel compressLevel, CompressionStrategy strategy)
        {
            buffer = new byte[size];
            // alloc 5 bytes overhead for every block (margin of safety= 2)
            int n = size + ((size / 32768) + 1) * 5 * 2;
            compressed = new byte[n];

            status = (int)Status.None;
            compressor = new ZlibCodec();
            compressor.InitializeDeflate(compressLevel, false);
            compressor.OutputBuffer = compressed;
            compressor.InputBuffer = buffer;
        }
开发者ID:nickchal,项目名称:pash,代码行数:13,代码来源:ParallelDeflateOutputStream.cs

示例2: WorkItem

 public WorkItem(int size,
                 Ionic.Zlib.CompressionLevel compressLevel,
                 CompressionStrategy strategy,
                 int ix)
 {
     this.buffer= new byte[size];
     // alloc 5 bytes overhead for every block (margin of safety= 2)
     int n = size + ((size / 32768)+1) * 5 * 2;
     this.compressed = new byte[n];
     this.compressor = new ZlibCodec();
     this.compressor.InitializeDeflate(compressLevel, false);
     this.compressor.OutputBuffer = this.compressed;
     this.compressor.InputBuffer = this.buffer;
     this.index = ix;
 }
开发者ID:Eagle-Chan,项目名称:KIS,代码行数:15,代码来源:ParallelDeflateOutputStream.cs

示例3: ParallelDeflateOutputStream

 /// <summary>
 /// Create a ParallelDeflateOutputStream using the specified
 /// CompressionLevel and CompressionStrategy, and specifying whether to
 /// leave the captive stream open when the ParallelDeflateOutputStream is
 /// closed.
 /// </summary>
 /// <remarks>
 ///   See the <see cref="ParallelDeflateOutputStream(System.IO.Stream)"/>
 ///   constructor for example code.
 /// </remarks>
 /// <param name="stream">The stream to which compressed data will be written.</param>
 /// <param name="level">A tuning knob to trade speed for effectiveness.</param>
 /// <param name="strategy">
 ///   By tweaking this parameter, you may be able to optimize the compression for
 ///   data with particular characteristics.
 /// </param>
 /// <param name="leaveOpen">
 ///    true if the application would like the stream to remain open after inflation/deflation.
 /// </param>
 public ParallelDeflateOutputStream(System.IO.Stream stream,
                                    CompressionLevel level,
                                    CompressionStrategy strategy,
                                    bool leaveOpen)
 {
     TraceOutput(TraceBits.Lifecycle | TraceBits.Session, "-------------------------------------------------------");
     TraceOutput(TraceBits.Lifecycle | TraceBits.Session, "Create {0:X8}", this.GetHashCode());
     _outStream = stream;
     _compressLevel= level;
     Strategy = strategy;
     _leaveOpen = leaveOpen;
     this.MaxBufferPairs = 16; // default
 }
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:32,代码来源:ParallelDeflateOutputStream.cs

示例4: WriterOptions

            public WriterOptions(Properties tableProperties, Configuration conf)
            {
                configuration = conf;
                memoryManagerValue = getMemoryManager(conf);
                stripeSizeValue = OrcConf.STRIPE_SIZE.getLong(tableProperties, conf);
                blockSizeValue = OrcConf.BLOCK_SIZE.getLong(tableProperties, conf);
                rowIndexStrideValue =
                    (int)OrcConf.ROW_INDEX_STRIDE.getLong(tableProperties, conf);
                bufferSizeValue = (int)OrcConf.BUFFER_SIZE.getLong(tableProperties,
                    conf);
                blockPaddingValue =
                    OrcConf.BLOCK_PADDING.getBoolean(tableProperties, conf);
                compressValue = (CompressionKind)Enum.Parse(
                    typeof(CompressionKind),
                    OrcConf.COMPRESS.getString(tableProperties, conf),
                    true);
                string versionName = OrcConf.WRITE_FORMAT.getString(tableProperties,
                    conf);
                versionValue = VersionHelper.byName(versionName);
                string enString = OrcConf.ENCODING_STRATEGY.getString(tableProperties,
                    conf);
                _encodingStrategy = (EncodingStrategy)Enum.Parse(typeof(EncodingStrategy), enString, true);

                string compString =
                    OrcConf.COMPRESSION_STRATEGY.getString(tableProperties, conf);
                compressionStrategy = (CompressionStrategy)Enum.Parse(typeof(CompressionStrategy), compString, true);

                _paddingTolerance =
                    OrcConf.BLOCK_PADDING_TOLERANCE.getDouble(tableProperties, conf);

                _bloomFilterColumns = OrcConf.BLOOM_FILTER_COLUMNS.getString(tableProperties,
                    conf);
                _bloomFilterFpp = OrcConf.BLOOM_FILTER_FPP.getDouble(tableProperties,
                    conf);
                timeZone = TimeZoneInfo.Local.Id;
            }
开发者ID:CurtHagenlocher,项目名称:OrcSharp,代码行数:36,代码来源:OrcFile.cs

示例5: SetParams

        internal int SetParams(CompressionLevel level, CompressionStrategy strategy)
        {
            int result = ZlibConstants.Z_OK;

            if (compressionLevel != level)
            {
                Config newConfig = Config.Lookup(level);

                // change in the deflate flavor (Fast vs slow vs none)?
                if (newConfig.Flavor != config.Flavor && _codec.TotalBytesIn != 0)
                {
                    // Flush the last buffer:
                    result = _codec.Deflate(FlushType.Partial);
                }

                compressionLevel = level;
                config = newConfig;
                SetDeflater();
            }

            // no need to flush with change in strategy?  Really?
            compressionStrategy = strategy;

            return result;
        }
开发者ID:JohnMalmsteen,项目名称:mobile-apps-tower-defense,代码行数:25,代码来源:Deflate.cs

示例6: Initialize

 internal int Initialize(ZlibCodec codec, CompressionLevel level, int bits, CompressionStrategy compressionStrategy)
 {
     return Initialize(codec, level, bits, MEM_LEVEL_DEFAULT, compressionStrategy);
 }
开发者ID:JohnMalmsteen,项目名称:mobile-apps-tower-defense,代码行数:4,代码来源:Deflate.cs

示例7: deflateInit2

        /// <summary>
        /// Deflate algorithm initialization
        /// </summary>
        /// <param name="strm">ZStream object</param>
        /// <param name="level">Compression level</param>
        /// <param name="method">Compression method</param>
        /// <param name="windowBits">Window bits</param>
        /// <param name="memLevel">Memory level</param>
        /// <param name="strategy">Compression strategy</param>
        /// <returns>Operation result code</returns>
        internal int deflateInit2(ZStream strm, int level, int method, int windowBits, int memLevel, CompressionStrategy strategy)
        {
            int noheader = 0;

            strm.msg = null;

            if (level == Z_DEFAULT_COMPRESSION)
                level = 6;

            if (windowBits < 0)
            {
                // undocumented feature: suppress zlib header
                noheader = 1;
                windowBits = -windowBits;
            }

            if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || windowBits < 9 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > CompressionStrategy.Z_HUFFMAN_ONLY)
            {
                return (int)ZLibResultCode.Z_STREAM_ERROR;
            }

            strm.dstate = (Deflate)this;

            this.NoHeader = noheader;
            w_bits = windowBits;
            w_size = 1 << w_bits;
            w_mask = w_size - 1;

            hash_bits = memLevel + 7;
            hash_size = 1 << hash_bits;
            hash_mask = hash_size - 1;
            hash_shift = ((hash_bits + MIN_MATCH - 1) / MIN_MATCH);

            window = new byte[w_size * 2];
            prev = new short[w_size];
            head = new short[hash_size];

            lit_bufsize = 1 << (memLevel + 6); // 16K elements by default

            // We overlay Pending_buf and d_buf+l_buf. This works since the average
            // output size for (length,distance) codes is <= 24 bits.
            Pending_buf = new byte[lit_bufsize * 4];
            pending_buf_size = lit_bufsize * 4;

            d_buf = lit_bufsize;
            l_buf = (1 + 2) * lit_bufsize;

            this.level = level;

            this.strategy = strategy;
            this.method = (byte)method;

            return deflateReset(strm);
        }
开发者ID:jschementi,项目名称:iron,代码行数:64,代码来源:Deflate.cs

示例8: DeflateInit2_

            public ErrorCode DeflateInit2_(CompressionLevel level, int windowBits, int memLevel, CompressionStrategy strategy)
            {
                EnsureNotDisposed();
                EnsureState(State.NotInitialized);

                ErrorCode errC = Interop.zlib.DeflateInit2_(ref _zStream, level, CompressionMethod.Deflated, windowBits, memLevel, strategy);
                _initializationState = State.InitializedForDeflate;

                return errC;
            }
开发者ID:Giftednewt,项目名称:corefx,代码行数:10,代码来源:ZLibNative.cs

示例9: Initialize

        internal int Initialize(ZlibCodec stream, CompressionLevel level, int method, int windowBits, int memLevel, CompressionStrategy strategy)
        {
            stream.Message = null;

            // validation
            if (windowBits < 9 || windowBits > 15)
                throw new ZlibException ("windowBits must be in the range 9..15.");

            if (memLevel < 1 || memLevel > MEM_LEVEL_MAX)
                throw new ZlibException (String.Format ("memLevel must be in the range 1.. {0}", MEM_LEVEL_MAX));

            if (method != Z_DEFLATED)
                throw new ZlibException ("Unexpected value for method: it must be Z_DEFLATED.");

            stream.dstate = this;

            w_bits = windowBits;
            w_size = 1 << w_bits;
            w_mask = w_size - 1;

            hash_bits = memLevel + 7;
            hash_size = 1 << hash_bits;
            hash_mask = hash_size - 1;
            hash_shift = ((hash_bits + MIN_MATCH - 1) / MIN_MATCH);

            window = new byte[w_size * 2];
            prev = new short[w_size];
            head = new short[hash_size];

            lit_bufsize = 1 << (memLevel + 6); // 16K elements by default

            // We overlay pending_buf and d_buf+l_buf. This works since the average
            // output size for (length,distance) codes is <= 24 bits.
            pending = new byte[lit_bufsize * 4];

            d_buf = lit_bufsize / 2;
            l_buf = (1 + 2) * lit_bufsize;

            this.compressionLevel = level;
            this.compressionStrategy = strategy;
            this.method = (sbyte)method;

            return Reset (stream);
        }
开发者ID:simonwittber,项目名称:netwrok-client,代码行数:44,代码来源:Deflate.cs

示例10: SetParams

        internal int SetParams(ZlibCodec strm, CompressionLevel _level, CompressionStrategy _strategy)
        {
            int result = ZlibConstants.Z_OK;

            if (configTable [(int)compressionLevel].func != configTable [(int)_level].func && strm.TotalBytesIn != 0) {
                // Flush the last buffer:
                result = strm.Deflate (ZlibConstants.Z_PARTIAL_FLUSH);
            }

            if (compressionLevel != _level) {
                compressionLevel = _level;
                max_lazy_match = configTable [(int)compressionLevel].max_lazy;
                good_match = configTable [(int)compressionLevel].good_length;
                nice_match = configTable [(int)compressionLevel].nice_length;
                max_chain_length = configTable [(int)compressionLevel].max_chain;
            }
            compressionStrategy = _strategy;
            return result;
        }
开发者ID:simonwittber,项目名称:netwrok-client,代码行数:19,代码来源:Deflate.cs

示例11: deflateParams

        /// <summary>
        /// Dynamically update the compression level and compression strategy. The interpretation of level is as in <see cref="deflateInit(int)"/>. This can be used to switch between compression and straight copy of the input data, or to switch to a different kind of input data requiring a different strategy. If the compression level is changed, the input available so far is compressed with the old level (and may be flushed); the new level will take effect only at the next call of <see cref="deflate" />
        /// </summary>
        /// <param name="level">An integer value indicating the desired compression level.</param>
        /// <param name="strategy">A <see cref="FlushStrategy">flush strategy</see> to use.</param>
        /// <remarks>
        /// Before the call of <see cref="deflateParams" />, the stream state must be set as for a call of <see cref="deflate" />, since the currently available input may have to be compressed and flushed. In particular, <see cref="avail_out" /> must be non-zero.
        /// </remarks>
        /// <returns>
        /// deflateParams returns <see cref="ZLibResultCode.Z_OK" /> if success, <see cref="ZLibResultCode.Z_STREAM_ERROR" /> if the source stream state was inconsistent or if a parameter was invalid, <see cref="ZLibResultCode.Z_BUF_ERROR" /> if <see cref="avail_out" /> was zero.
        /// </returns>
		public int deflateParams(int level, CompressionStrategy strategy)
		{
			if (_dstate == null)
				return (int)ZLibResultCode.Z_STREAM_ERROR;
			return _dstate.deflateParams(this, level, strategy);
		}
开发者ID:Jirapong,项目名称:main,代码行数:17,代码来源:ZStream.cs

示例12: deflateInit

 public int deflateInit(int level, int windowBits, int memLevel, CompressionStrategy strategy) {
     _dstate = new Deflate();
     return _dstate.deflateInit2(this, level, windowBits, memLevel, strategy);
 }
开发者ID:TerabyteX,项目名称:main,代码行数:4,代码来源:ZStream.cs

示例13: Initialize

        internal int Initialize( ZlibCodec codec, CompressionLevel level, int windowBits, int memLevel, CompressionStrategy strategy )
        {
            _codec = codec;
            _codec.Message = null;

            if ( windowBits < 9 || windowBits > 15 )
                throw new CompressionProcessException ( "windowBits must be in the range 9..15." );

            if ( memLevel < 1 || memLevel > MEM_LEVEL_MAX )
                throw new CompressionProcessException ( String.Format ( "memLevel must be in the range 1.. {0}", MEM_LEVEL_MAX ) );

            _codec.dstate = this;

            w_bits = windowBits;
            w_size = 1 << w_bits;
            w_mask = w_size - 1;

            hash_bits = memLevel + 7;
            hash_size = 1 << hash_bits;
            hash_mask = hash_size - 1;
            hash_shift = ( ( hash_bits + MIN_MATCH - 1 ) / MIN_MATCH );

            window = new byte [ w_size * 2 ];
            prev = new short [ w_size ];
            head = new short [ hash_size ];

            lit_bufsize = 1 << ( memLevel + 6 );

            pending = new byte [ lit_bufsize * 4 ];
            _distanceOffset = lit_bufsize;
            _lengthOffset = ( 1 + 2 ) * lit_bufsize;

            this.compressionLevel = level;
            this.compressionStrategy = strategy;

            Reset ();
            return ZlibConstants.Z_OK;
        }
开发者ID:Daramkun,项目名称:ProjectLiqueur,代码行数:38,代码来源:Deflate.cs

示例14: SetParams

        internal int SetParams( CompressionLevel level, CompressionStrategy strategy )
        {
            int result = ZlibConstants.Z_OK;

            if ( compressionLevel != level )
            {
                Config newConfig = Config.Lookup ( level );

                if ( newConfig.Flavor != config.Flavor && _codec.TotalBytesIn != 0 )
                {
                    result = _codec.Deflate ( FlushType.Partial );
                }

                compressionLevel = level;
                config = newConfig;
                SetDeflater ();
            }

            compressionStrategy = strategy;

            return result;
        }
开发者ID:Daramkun,项目名称:ProjectLiqueur,代码行数:22,代码来源:Deflate.cs

示例15: deflateInit2

        private ZLibStatus deflateInit2(CompressionLevel level, int method, int windowBits, int memLevel, CompressionStrategy strategy)
        {
            int noheader = 0;
            //    byte[] my_version=ZLIB_VERSION;

            //
            //  if (version == null || version[0] != my_version[0]
            //  || stream_size != sizeof(z_stream)) {
            //  return Z_VERSION_ERROR;
            //  }

            base.msg = null;

            if (level == CompressionLevel.Z_DEFAULT_COMPRESSION) level = (CompressionLevel)6;

            if (windowBits < 0)
            { // undocumented feature: suppress zlib header
                noheader = 1;
                windowBits = -windowBits;
            }

            if (memLevel < 1 || memLevel > MAX_MEM_LEVEL ||
                method != Z_DEFLATED ||
                windowBits < 9 || windowBits > 15 || level < 0 || level > (CompressionLevel)9 ||
                strategy < 0 || strategy > CompressionStrategy.Z_HUFFMAN_ONLY)
            {
                return ZLibStatus.Z_STREAM_ERROR;
            }

            this.noheader = noheader;
            _windowBits = windowBits;
            _windowSize = 1 << _windowBits;
            _windowMask = _windowSize - 1;

            _hashBits = memLevel + 7;
            _hashSize = 1 << _hashBits;
            _hashMask = _hashSize - 1;
            _hashShift = ((_hashBits + MIN_MATCH - 1) / MIN_MATCH);

            _window = new byte[_windowSize * 2];
            _previous = new short[_windowSize];
            _head = new short[_hashSize];

            lit_bufsize = 1 << (memLevel + 6); // 16K elements by default

            // We overlay pending_buf and d_buf+l_buf. This works since the average
            // output size for (length,distance) codes is <= 24 bits.
            pending_buf = new byte[lit_bufsize * 4];
            _pendingBufferSize = lit_bufsize * 4;

            d_buf = lit_bufsize / 2;
            l_buf = (1 + 2) * lit_bufsize;

            this.level = level;

            //System.out.println("level="+level);

            this.strategy = strategy;
            this._method = (byte)method;

            return deflateReset();
        }
开发者ID:imbavirus,项目名称:TrinityCoreAdmin,代码行数:62,代码来源:Deflate.cs


注:本文中的CompressionStrategy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。