Here you can find the source of splitVertically(BufferedImage top, int elements)
public static BufferedImage[] splitVertically(BufferedImage top, int elements)
//package com.java2s; //License from project: Apache License import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.image.BufferedImage; public class Main { public static BufferedImage[] splitVertically(BufferedImage top, int elements) { int currentY = 0; int stepY = top.getHeight() / elements; BufferedImage[] images = new BufferedImage[elements]; for (int i = 0; i < elements; i++) { images[i] = croppedCopy(top, 0, currentY, top.getWidth(), currentY + stepY); currentY += stepY;/*from w w w .j av a2 s .co m*/ } return images; } public static BufferedImage croppedCopy(BufferedImage image, int startX, int startY, int endX, int endY) { int width = endX - startX; int height = endY - startY; BufferedImage cropped = new BufferedImage(width, height, image.getType()); Graphics2D graphics2d = cropped.createGraphics(); graphics2d.drawImage(image, 0, 0, width, height, startX, startY, endX, endY, null); graphics2d.dispose(); return cropped; } public static BufferedImage croppedCopy(BufferedImage championRow, Rectangle rect) { return croppedCopy(championRow, rect.x, rect.y, rect.x + rect.width, rect.y + rect.height); } }