private void setCounters ( BitArray row ) throws NotFoundException { counterLength = 0 ; // Start from the first white bit. int i = row . getNextUnset ( 0 ) ; int end = row . getSize ( ) ; if ( i >= end ) { throw NotFoundException . getNotFoundInstance ( ) ; } boolean isWhite = true ; int count = 0 ; while ( i < end ) { if ( row . get ( i ) != isWhite ) { count ++ ; } else { counterAppend ( count ) ; count = 1 ; isWhite = ! isWhite ; } i ++ ; } counterAppend ( count ) ; }
Records the size of all runs of white and black pixels starting with white . This is just like recordPattern except it records all the counters and uses our builtin counters member for storage .