int height = (int) (topTile - bottomTile + 1) * DEFAULT_TILE_SIZE;
//recalculate the envelope we are actually returning
resultEnvelope = new ReferencedEnvelope(offsetX + leftTile * resX, offsetX + (rightTile+1) * resX, offsetY + bottomTile * resY, offsetY + (topTile+1) * resY, crs);
TileReader it;
it = file.reader(entry, bestMatrix.getZoomLevel(), bestMatrix.getZoomLevel(), leftTile, rightTile, bottomTile, topTile);
while (it.hasNext()) {
Tile tile = it.next();
BufferedImage tileImage = readImage(tile.getData());
if (image == null) {
image = getStartImage(tileImage, width, height);
}
//coordinates
int posx = (int) (tile.getColumn() - leftTile) * DEFAULT_TILE_SIZE;
int posy = (int) (topTile - tile.getRow()) * DEFAULT_TILE_SIZE;
image.getRaster().setRect(posx, posy, tileImage.getData() );
}
it.close();
if (image == null){ // no tiles ??
image = getStartImage(width, height);
}
}