private int [ ] readColorTable ( int ncolors ) { int nbytes = 3 * ncolors ; int [ ] tab = null ; byte [ ] c = new byte [ nbytes ] ; try { rawData . get ( c ) ; // Max size to avoid bounds checks. tab = new int [ MAX_BLOCK_SIZE ] ; int i = 0 ; int j = 0 ; while ( i < ncolors ) { int r = ( ( int ) c [ j ++ ] ) & 0xff ; int g = ( ( int ) c [ j ++ ] ) & 0xff ; int b = ( ( int ) c [ j ++ ] ) & 0xff ; tab [ i ++ ] = 0xff000000 | ( r << 16 ) | ( g << 8 ) | b ; } } catch ( BufferUnderflowException e ) { //if (Log.isLoggable(TAG, Log.DEBUG)) { Logger . d ( TAG , "Format Error Reading Color Table" , e ) ; //} header . status = GifDecoder . STATUS_FORMAT_ERROR ; } return tab ; }
Reads color table as 256 RGB integer values .