Here you can find the source of arrayToMatrix(int[] m, int width, int height)
public static int[][] arrayToMatrix(int[] m, int width, int height)
//package com.java2s; public class Main { public static int[][] arrayToMatrix(int[] m, int width, int height) { int[][] result = new int[height][width]; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { int p = j * height + i; result[i][j] = m[p];/* ww w. j av a 2 s .c o m*/ } } return result; } }