code: public static void getTile (int width, int height, int tileWidth, int tileHeight, int tileIndex,
                                  Rectangle bounds)
      {
          // figure out from whence to crop the tile
          int tilesPerRow = width / tileWidth;
  
          // if we got a bogus region, return bogus tile bounds
          if (tilesPerRow == 0) {
              bounds.setBounds(0, 0, width, height);
  
          } else {
              int row = tileIndex / tilesPerRow;
              int col = tileIndex % tilesPerRow;
              // crop the tile-sized image chunk from the full image
              bounds.setBounds(tileWidth*col, tileHeight*row, tileWidth, tileHeight);
          }
      }
docs: Fills in the bounds of the specified tile in the supplied larger rectangle. Tiles go from
  left to right, top to bottom.