Here you can find the source of copyArray(int[][][] data)
Parameter | Description |
---|---|
data | The data to duplicate |
public static int[][][] copyArray(int[][][] data)
//package com.java2s; /*//from www . j a v a2 s .c o m * The MIT License (MIT) * * Copyright (c) 2015 Ziver Koc * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ public class Main { /** * Copies the given array to a new one that it returns * * @param data The data to duplicate * @return an copy of the array */ public static int[][][] copyArray(int[][][] data) { return copyArray(data, 0, 0, data[0].length, data.length); } /** * Copies the given array to a new one that it returns * * @param data The data to duplicate * @param startX is the x pixel of the image to start from * @param startY is the y pixel of the image to start from * @param stopX is the x pixel of the image to stop * @param stopY is the y pixel of the image to stop * @return The array copy */ public static int[][][] copyArray(int[][][] data, int startX, int startY, int stopX, int stopY) { int[][][] copy = new int[data.length][data[0].length][4]; return copyArray(data, copy, startX, startY, stopX, stopY); } /** * Copies the given array to a new one that it returns * * @param data The data to duplicate * @param dest is the array to copy the data to * @param startX is the x pixel of the image to start from * @param startY is the y pixel of the image to start from * @param stopX is the x pixel of the image to stop * @param stopY is the y pixel of the image to stop * @return the dest array */ public static int[][][] copyArray(int[][][] data, int[][][] dest, int startX, int startY, int stopX, int stopY) { for (int y = startY; y < stopY; y++) { for (int x = startX; x < stopX; x++) { dest[y][x][0] = data[y][x][0]; dest[y][x][1] = data[y][x][1]; dest[y][x][2] = data[y][x][2]; dest[y][x][3] = data[y][x][3]; } } return dest; } }