public int [ ] convertToArray ( ) { int [ ] p = new int [ size ] ; for ( int j = 0 ; j < height ; ++ j ) { for ( int i = 0 ; i < width ; ++ i ) { p [ ( j * width ) + i ] = pixels [ i ] [ j ] ; } } return p ; }
Converts the 2D array into a 1D array of pixel values .