Examples of NBitInputStream


Examples of org.apache.pdfbox.io.NBitInputStream

     */
    public void decode( InputStream compressedData, OutputStream result, COSDictionary options, int filterIndex )
        throws IOException
    {
        //log.debug("decode( )");
        NBitInputStream in = null;
        in = new NBitInputStream( compressedData );
        in.setBitsInChunk( 9 );
        LZWDictionary dic = new LZWDictionary();
        byte firstByte = 0;
        long nextCommand = 0;
        while( (nextCommand = in.read() ) != EOD )
        {
            // log.debug( "decode - nextCommand=" + nextCommand + ", bitsInChunk: " + in.getBitsInChunk());

            if( nextCommand == CLEAR_TABLE )
            {
                in.setBitsInChunk( 9 );
                dic = new LZWDictionary();
            }
            else
            {
                byte[] data = dic.getData( nextCommand );
                if( data == null )
                {
                    dic.visit( firstByte );
                    data = dic.getData( nextCommand );
                    dic.clear();
                }
                if( data == null )
                {
                    throw new StreamCorruptedException( "Error: data is null" );
                }
                dic.visit(data);

                //log.debug( "decode - dic.getNextCode(): " + dic.getNextCode());

                if( dic.getNextCode() >= 2047 )
                {
                    in.setBitsInChunk( 12 );
                }
                else if( dic.getNextCode() >= 1023 )
                {
                    in.setBitsInChunk( 11 );
                }
                else if( dic.getNextCode() >= 511 )
                {
                    in.setBitsInChunk( 10 );
                }
                else
                {
                    in.setBitsInChunk( 9 );
                }
                /**
                if( in.getBitsInChunk() != dic.getCodeSize() )
                {
                    in.unread( nextCommand );
View Full Code Here

Examples of org.pdfbox.io.NBitInputStream

     * @throws IOException If there is an error decompressing the stream.
     */
    public void decode( InputStream compressedData, OutputStream result, COSDictionary options ) throws IOException
    {
        //log.debug("decode( )");
        NBitInputStream in = null;
        in = new NBitInputStream( compressedData );
        in.setBitsInChunk( 9 );
        LZWDictionary dic = new LZWDictionary();
        byte firstByte = 0;
        long nextCommand = 0;
        while( (nextCommand = in.read() ) != EOD )
        {
            // log.debug( "decode - nextCommand=" + nextCommand + ", bitsInChunk: " + in.getBitsInChunk());

            if( nextCommand == CLEAR_TABLE )
            {
                in.setBitsInChunk( 9 );
                dic = new LZWDictionary();
            }
            else
            {
                byte[] data = dic.getData( nextCommand );
                if( data == null )
                {
                    dic.visit( firstByte );
                    data = dic.getData( nextCommand );
                    dic.clear();
                }
                if( data == null )
                {
                    throw new StreamCorruptedException( "Error: data is null" );
                }
                dic.visit(data);

                //log.debug( "decode - dic.getNextCode(): " + dic.getNextCode());

                if( dic.getNextCode() >= 2047 )
                {
                    in.setBitsInChunk( 12 );
                }
                else if( dic.getNextCode() >= 1023 )
                {
                    in.setBitsInChunk( 11 );
                }
                else if( dic.getNextCode() >= 511 )
                {
                    in.setBitsInChunk( 10 );
                }
                else
                {
                    in.setBitsInChunk( 9 );
                }
                /**
                if( in.getBitsInChunk() != dic.getCodeSize() )
                {
                    in.unread( nextCommand );
View Full Code Here

Examples of org.pdfbox.io.NBitInputStream

     * @throws IOException If there is an error decompressing the stream.
     */
    public void decode( InputStream compressedData, OutputStream result, COSDictionary options ) throws IOException
    {
        //log.debug("decode( )");
        NBitInputStream in = null;
        in = new NBitInputStream( compressedData );
        in.setBitsInChunk( 9 );
        LZWDictionary dic = new LZWDictionary();
        byte firstByte = 0;
        long nextCommand = 0;
        while( (nextCommand = in.read() ) != EOD )
        {
            // log.debug( "decode - nextCommand=" + nextCommand + ", bitsInChunk: " + in.getBitsInChunk());

            if( nextCommand == CLEAR_TABLE )
            {
                in.setBitsInChunk( 9 );
                dic = new LZWDictionary();
            }
            else
            {
                byte[] data = dic.getData( nextCommand );
                if( data == null )
                {
                    dic.visit( firstByte );
                    data = dic.getData( nextCommand );
                    dic.clear();
                }
                dic.visit(data);

                //log.debug( "decode - dic.getNextCode(): " + dic.getNextCode());

                if( dic.getNextCode() >= 2047 )
                {
                    in.setBitsInChunk( 12 );
                }
                else if( dic.getNextCode() >= 1023 )
                {
                    in.setBitsInChunk( 11 );
                }
                else if( dic.getNextCode() >= 511 )
                {
                    in.setBitsInChunk( 10 );
                }
                else
                {
                    in.setBitsInChunk( 9 );
                }
                /**
                if( in.getBitsInChunk() != dic.getCodeSize() )
                {
                    in.unread( nextCommand );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.