Here you can find the source of array1Dto2D(int[] d1, int imageWidth, int imageHeight)
public static int[][] array1Dto2D(int[] d1, int imageWidth, int imageHeight)
//package com.java2s; /* ArrayUtil.java 1.0 2010-2-2 * //from w w w . j a v a 2s. com * Copyright (c) 2010 by Chen Zhiwu * All rights reserved. * * The copyright of this software is own by the authors. * You may not use, copy or modify this software, except * in accordance with the license agreement you entered into * with the copyright holders. For details see accompanying license * terms. */ public class Main { public static int[][] array1Dto2D(int[] d1, int imageWidth, int imageHeight) { int[][] d2 = new int[imageHeight][imageWidth]; for (int h = 0; h < imageHeight; h++) { System.arraycopy(d1, h * imageWidth, d2[h], 0, imageWidth); } return d2; } public static void array1Dto2D(int[] d1, int[][] d2, int imageWidth, int imageHeight) { for (int h = 0; h < imageHeight; h++) { System.arraycopy(d1, h * imageWidth, d2[h], 0, imageWidth); } } }