Here you can find the source of splitImage(BufferedImage image, int row, int col)
Parameter | Description |
---|---|
image | a parameter |
row | a parameter |
col | a parameter |
public static BufferedImage[] splitImage(BufferedImage image, int row, int col)
//package com.java2s; /*/*from w ww. ja v a2s.com*/ * leola-live * see license.txt */ import java.awt.image.BufferedImage; public class Main { /** * Splits the image, uses the image width/height * @param image * @param row * @param col * @return */ public static BufferedImage[] splitImage(BufferedImage image, int row, int col) { return splitImage(image, image.getWidth(), image.getHeight(), row, col); } /** * Splits the image * @param image * @param width * @param height * @param row * @param col * @return */ public static BufferedImage[] splitImage(BufferedImage image, int width, int height, int row, int col) { int total = col * row; // total returned images int frame = 0; // frame counter int w = width / col; int h = height / row; BufferedImage[] images = new BufferedImage[total]; for (int j = 0; j < row; j++) { for (int i = 0; i < col; i++) { BufferedImage tmp = image.getSubimage(i * w, j * h, w, h); images[frame++] = tmp; } } return images; } }