protected void readImage ( ) throws IOException { ix = readShort ( ) ; // (sub)image position & size iy = readShort ( ) ; iw = readShort ( ) ; ih = readShort ( ) ; int packed = in . read ( ) ; lctFlag = ( packed & 0x80 ) != 0 ; // 1 - local color table flag interlace = ( packed & 0x40 ) != 0 ; // 2 - interlace flag // 3 - sort flag // 4-5 - reserved lctSize = 2 << ( packed & 7 ) ; // 6-8 - local color table size m_bpc = newBpc ( m_gbpc ) ; if ( lctFlag ) { m_curr_table = readColorTable ( ( packed & 7 ) + 1 ) ; // read table m_bpc = newBpc ( ( packed & 7 ) + 1 ) ; } else { m_curr_table = m_global_table ; } if ( transparency && transIndex >= m_curr_table . length / 3 ) { transparency = false ; } if ( transparency && m_bpc == 1 ) { // Acrobat 5.05 doesn't like this combination byte tp [ ] = new byte [ 12 ] ; System . arraycopy ( m_curr_table , 0 , tp , 0 , 6 ) ; m_curr_table = tp ; m_bpc = 2 ; } boolean skipZero = decodeImageData ( ) ; // decode pixel data if ( ! skipZero ) skip ( ) ; Image img = null ; try { img = new ImgRaw ( iw , ih , 1 , m_bpc , m_out ) ; PdfArray colorspace = new PdfArray ( ) ; colorspace . add ( PdfName . INDEXED ) ; colorspace . add ( PdfName . DEVICERGB ) ; int len = m_curr_table . length ; colorspace . add ( new PdfNumber ( len / 3 - 1 ) ) ; colorspace . add ( new PdfString ( m_curr_table ) ) ; PdfDictionary ad = new PdfDictionary ( ) ; ad . put ( PdfName . COLORSPACE , colorspace ) ; img . setAdditional ( ad ) ; if ( transparency ) { img . setTransparency ( new int [ ] { transIndex , transIndex } ) ; } } catch ( Exception e ) { throw new ExceptionConverter ( e ) ; } img . setOriginalType ( Image . ORIGINAL_GIF ) ; img . setOriginalData ( fromData ) ; img . setUrl ( fromUrl ) ; GifFrame gf = new GifFrame ( ) ; gf . image = img ; gf . ix = ix ; gf . iy = iy ; frames . add ( gf ) ; // add image to frame list //resetFrame(); }
Reads next frame image