Here you can find the source of splitImage(BufferedImage img, int rows, int cols)
public static BufferedImage[] splitImage(BufferedImage img, int rows, int cols)
//package com.java2s; //License from project: Apache License import java.awt.image.BufferedImage; public class Main { public static BufferedImage[] splitImage(BufferedImage img, int rows, int cols) { if (img == null) throw new IllegalArgumentException("Image cannot be null!"); if (rows < 1 || cols < 1) throw new IllegalArgumentException("Rows and columns must be at least 1!"); BufferedImage[] bufs = new BufferedImage[rows * cols]; int width = img.getWidth() / cols; int height = img.getHeight() / rows; for (int i = 0; i < bufs.length; i++) bufs[i] = img.getSubimage(i % cols * width, i / cols * height, width, height); return bufs; }// w ww . j a va 2 s .c o m }