Android Array to Matrix Convert arrayToMatrix(int[] m, int width, int height)

Here you can find the source of arrayToMatrix(int[] m, int width, int height)

Description

array To Matrix

Declaration

public static int[][] arrayToMatrix(int[] m, int width, int height) 

Method Source Code

//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;
    }
}