code: private static Tile checkTile(MapTile map, ImageBuffer tileSprite, Integer sheet, int x, int y)
      {
          final int tw = map.getTileWidth();
          final int th = map.getTileHeight();
          final SpriteTiled tileSheet = map.getSheet(sheet);
          final ImageBuffer sheetImage = tileSheet.getSurface();
          final int tilesInX = tileSheet.getWidth() / tw;
          final int tilesInY = tileSheet.getHeight() / th;
  
          for (int surfaceCurrentTileY = 0; surfaceCurrentTileY < tilesInY; surfaceCurrentTileY++)
          {
              for (int surfaceCurrentTileX = 0; surfaceCurrentTileX < tilesInX; surfaceCurrentTileX++)
              {
                  // Tile number on tile sheet
                  final int number = surfaceCurrentTileX + surfaceCurrentTileY * tilesInX;
  
                  // Compare tiles between sheet and image map
                  final int xa = x * tw;
                  final int ya = y * th;
                  final int xb = surfaceCurrentTileX * tw;
                  final int yb = surfaceCurrentTileY * th;
  
                  if (TilesExtractor.compareTile(tw, th, tileSprite, xa, ya, sheetImage, xb, yb))
                  {
                      return map.createTile(sheet, number, xa, (map.getInTileHeight() - 1.0 - y) * th);
                  }
              }
          }
          return null;
      }
docs: Check tile of sheet.
  
  @param map The destination map reference.
  @param tileSprite The tiled sprite
  @param sheet The sheet number.
  @param x The location x.
  @param y The location y.
  @return The tile found.