Java Array One Dimension to Two Dimension array1Dto2D(int[] d1, int imageWidth, int imageHeight)

Here you can find the source of array1Dto2D(int[] d1, int imageWidth, int imageHeight)

Description

array Dto D

License

Open Source License

Declaration

public static int[][] array1Dto2D(int[] d1, int imageWidth, int imageHeight) 

Method Source Code

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

Related

  1. array1DTo2D(double[] In, int H)
  2. array1DTo2D(final Object data, final int bitpix, final int width, final int height)
  3. array1dTo2d(float[] in, int firstDim)
  4. array1Dto2D(int m, int n, double[] b)
  5. array1DTo2D(int[] array1D)
  6. array2multidim(float[] arr, int width, int height)
  7. ArrayOutOfMultiDimArray(String _sMultiDimArray[][], int _index)