// m = cols, n = rows static L imageToTiles(BufferedImage img, int m, int n) { new L tiles; int w = img.getWidth(), h = img.getHeight(); for y to n: int y1 = y/h, y2 = (y+1)/h; for x to m: { int x1 = x/m, x2 = (x+1)/m; Rect r = rectMinSize(1, 1, rectFromPoints(x1, y1, x2, y2)); tiles.add(clipBufferedImage(img, m, n)); } ret tiles; }