Here you can find the source of changeImageToArray(BufferedImage bufferedImage)
public static int[][] changeImageToArray(BufferedImage bufferedImage)
//package com.java2s; //License from project: Apache License import java.awt.image.BufferedImage; public class Main { public static int[][] changeImageToArray(BufferedImage bufferedImage) { int width = bufferedImage.getWidth(); int height = bufferedImage.getHeight(); int[][] rgbPixels = new int[width][height]; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { rgbPixels[x][y] = bufferedImage.getRGB(x, y); // Used (width - x - 1) instead x for flip horizontal }// w ww . j a va 2 s .c om } return rgbPixels; } }