Here you can find the source of cutImage(BufferedImage img, int w, int h)
public static BufferedImage[] cutImage(BufferedImage img, int w, int h)
//package com.java2s; //License from project: Open Source License import java.awt.image.BufferedImage; public class Main { public static BufferedImage[] cutImage(BufferedImage img, int w, int h) { int cols = img.getWidth() / w; int rows = img.getHeight() / h; BufferedImage[] tiles = new BufferedImage[cols * rows]; for (int x = 0; x < cols; x++) { for (int y = 0; y < rows; y++) { tiles[x + y * cols] = img.getSubimage(x * w, y * h, w, h); }//from w ww . java 2 s.co m } return tiles; } }