code: 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;
      }
docs: Converts the 2D array into a 1D array of pixel values.
  
  @return The 1D array of pixel values.