Here you can find the source of buildSectors(BufferedImage a, int sqrtSectors)
private static Rectangle[] buildSectors(BufferedImage a, int sqrtSectors)
//package com.java2s; //License from project: Apache License import java.awt.Rectangle; import java.awt.image.BufferedImage; public class Main { private static Rectangle[] buildSectors(BufferedImage a, int sqrtSectors) { int rows = sqrtSectors; int columns = sqrtSectors; int sectorWidth = a.getWidth() / columns; int sectorHeight = a.getHeight() / columns; Rectangle[] sectors = new Rectangle[sqrtSectors * sqrtSectors]; for (int x = 0; x < columns; x++) { for (int y = 0; y < rows; y++) { int sectorStartX = x * sectorWidth; int sectorStartY = y * sectorHeight; int index = x + y * columns; sectors[index] = new Rectangle(sectorStartX, sectorStartY, sectorWidth, sectorHeight); }//from w ww . ja v a 2 s . c o m } return sectors; } }