xRemaining = img.getWidth()-1;
for (int x = 0; x < img.getWidth(); x += wStep) {
yRemaining = img.getHeight()-1;
for (int y = 0; y < img.getHeight(); y += hStep) {
rect = new Rectangle(x,y,Math.min(wStep, xRemaining),Math.min(hStep, yRemaining));
fs = fc.gather(img.getSubimage(x, y, rect.width, rect.height), "", cellDim);
grid.add(new Cell(rect,fs));
yRemaining -= hStep;
}
xRemaining -= wStep;
}