ClearTable() public méthode

public ClearTable ( int codesize ) : void
codesize int
Résultat void
Exemple #1
0
        /**
         * @param outp destination for compressed data
         * @param codeSize the initial code size for the LZW compressor
         * @param TIFF flag indicating that TIFF lzw fudge needs to be applied
         * @exception IOException if underlying output stream error
         **/
        public LZWCompressor(Stream outp, int codeSize, bool TIFF)
        {
            bf_        = new BitFile(outp, !TIFF); // set flag for GIF as NOT tiff
            codeSize_  = codeSize;
            tiffFudge_ = TIFF;
            clearCode_ = 1 << codeSize_;
            endOfInfo_ = clearCode_ + 1;
            numBits_   = codeSize_ + 1;

            limit_ = (1 << numBits_) - 1;
            if (tiffFudge_)
            {
                --limit_;
            }

            prefix_ = -1;
            lzss_   = new LZWStringTable();
            lzss_.ClearTable(codeSize_);
            bf_.WriteBits(clearCode_, numBits_);
        }
Exemple #2
0
        /**
         * @param buf data to be compressed to output stream
         * @exception IOException if underlying output stream error
         **/
        public void Compress(byte[] buf, int offset, int length)
        {
            int   idx;
            byte  c;
            short index;

            int maxOffset = offset + length;

            for (idx = offset; idx < maxOffset; ++idx)
            {
                c = buf[idx];
                if ((index = lzss_.FindCharString(prefix_, c)) != -1)
                {
                    prefix_ = index;
                }
                else
                {
                    bf_.WriteBits(prefix_, numBits_);
                    if (lzss_.AddCharString(prefix_, c) > limit_)
                    {
                        if (numBits_ == 12)
                        {
                            bf_.WriteBits(clearCode_, numBits_);
                            lzss_.ClearTable(codeSize_);
                            numBits_ = codeSize_ + 1;
                        }
                        else
                        {
                            ++numBits_;
                        }

                        limit_ = (1 << numBits_) - 1;
                        if (tiffFudge_)
                        {
                            --limit_;
                        }
                    }
                    prefix_ = (short)((short)c & 0xFF);
                }
            }
        }
        /**
         * @param outp destination for compressed data
         * @param codeSize the initial code size for the LZW compressor
         * @param TIFF flag indicating that TIFF lzw fudge needs to be applied
         * @exception IOException if underlying output stream error
         **/
        public LZWCompressor(Stream outp, int codeSize, bool TIFF)
        {
            bf_ = new BitFile(outp, !TIFF);	// set flag for GIF as NOT tiff
            codeSize_ = codeSize;
            tiffFudge_ = TIFF;
            clearCode_ = 1 << codeSize_;
            endOfInfo_ = clearCode_ + 1;
            numBits_ = codeSize_ + 1;

            limit_ = (1 << numBits_) - 1;
            if (tiffFudge_)
                --limit_;

            prefix_ = -1;
            lzss_ = new LZWStringTable();
            lzss_.ClearTable(codeSize_);
            bf_.WriteBits(clearCode_, numBits_);
        }