public InputStream getTileAsBytes(final int tileX, final int tileY, final byte zoomLevel) {
        final long tmsTileY = tileYToTMS(tileY, zoomLevel);
        try (Cursor cursor = database.rawQuery(String.format(SELECT_TILES, zoomLevel, tileX, tmsTileY), null)) {
            if (cursor.moveToNext()) {
                final int i = cursor.getColumnIndex("tile_data");
                return i < 0 ? null : new ByteArrayInputStream(cursor.getBlob(i));
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        return null;
    }
Converts a tile Y number at a certain zoom level to TMS notation.

@param tileY     the tile Y number that should be converted.
@param zoomLevel the zoom level at which the number should be converted.
@return the TMS value of the tile Y number.
main/src/main/java/cgeo/geocaching/unifiedmap/layers/mbtiles/MBTilesFile.java