ICSharpCode.SharpZipLib.Zip.Compression.DeflaterHuffman.FlushStoredBlock C# (CSharp) Method

FlushStoredBlock() public method

Flush block to output with no compression
public FlushStoredBlock ( byte stored, int storedOffset, int storedLength, bool lastBlock ) : void
stored byte Data to write
storedOffset int Index of first byte to write
storedLength int Count of bytes to write
lastBlock bool True if this is the last block
return void
        public void FlushStoredBlock(byte[] stored, int storedOffset, int storedLength, bool lastBlock)
        {
            #if DebugDeflation
            //			if (DeflaterConstants.DEBUGGING) {
            //				//Console.WriteLine("Flushing stored block "+ storedLength);
            //			}
            #endif
            pending.WriteBits((DeflaterConstants.STORED_BLOCK << 1) + (lastBlock ? 1 : 0), 3);
            pending.AlignToByte();
            pending.WriteShort(storedLength);
            pending.WriteShort(~storedLength);
            pending.WriteBlock(stored, storedOffset, storedLength);
            Reset();
        }

Usage Example

Ejemplo n.º 1
0
        /// <summary>
        /// Set the deflate level (0-9)
        /// </summary>
        /// <param name="level">The value to set the level to.</param>
        public void SetLevel(int level)
        {
            if ((level < 0) || (level > 9))
            {
                throw new ArgumentOutOfRangeException("level");
            }

            goodLength = DeflaterConstants.GOOD_LENGTH[level];
            max_lazy   = DeflaterConstants.MAX_LAZY[level];
            niceLength = DeflaterConstants.NICE_LENGTH[level];
            max_chain  = DeflaterConstants.MAX_CHAIN[level];

            if (DeflaterConstants.COMPR_FUNC[level] != compressionFunction)
            {
            #if DebugDeflation
                if (DeflaterConstants.DEBUGGING)
                {
                    Console.WriteLine("Change from " + compressionFunction + " to "
                                      + DeflaterConstants.COMPR_FUNC[level]);
                }
            #endif
                switch (compressionFunction)
                {
                case DEFLATE_STORED:
                    if (strstart > blockStart)
                    {
                        huffman.FlushStoredBlock(window, blockStart,
                                                 strstart - blockStart, false);
                        blockStart = strstart;
                    }
                    UpdateHash();
                    break;

                case DEFLATE_FAST:
                    if (strstart > blockStart)
                    {
                        huffman.FlushBlock(window, blockStart, strstart - blockStart,
                                           false);
                        blockStart = strstart;
                    }
                    break;

                case DEFLATE_SLOW:
                    if (prevAvailable)
                    {
                        huffman.TallyLit(window[strstart - 1] & 0xff);
                    }
                    if (strstart > blockStart)
                    {
                        huffman.FlushBlock(window, blockStart, strstart - blockStart, false);
                        blockStart = strstart;
                    }
                    prevAvailable = false;
                    matchLen      = MIN_MATCH - 1;
                    break;
                }
                compressionFunction = COMPR_FUNC[level];
            }
        }
All Usage Examples Of ICSharpCode.SharpZipLib.Zip.Compression.DeflaterHuffman::FlushStoredBlock