question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tiles Scaled To Dpi on high DPI sources

See original GitHub issue

In current implementation if we have high DPI sources with 512px tiles

private void updateTileSizeForDensity(final ITileSource aTileSource) {
	float density = isTilesScaledToDpi() ? getResources().getDisplayMetrics().density : 1;
	TileSystem.setTileSize((int) (aTileSource.getTileSizePixels() * density));
}

produce wrong value for tile size. For devices with 3x density tile size become 1536 (512 *3) my solution is this

private void updateTileSizeForDensity(final ITileSource aTileSource) {
        int tile_size = aTileSource.getTileSizePixels();
        float density =  getResources().getDisplayMetrics().density * 256 / tile_size ;
        int size = (int) ( tile_size * (isTilesScaledToDpi() ? density : 1));
        TileSystem.setTileSize(size);
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
wolojolicommented, Dec 9, 2016

This is even shorter ’ private void updateTileSizeForDensity(final ITileSource aTileSource) { int size = (int) ( isTilesScaledToDpi() ? getResources().getDisplayMetrics().density * 256 :aTileSource.getTileSizePixels()); TileSystem.setTileSize(size); } ’

0reactions
sandman7920commented, Dec 9, 2016

But if isTilesScaledToDpi() returns false aTileSource.getTileSizePixels() must be used

Read more comments on GitHub >

github_iconTop Results From Across the Web

QGIS - exporting open source tiled maps at high dpi or ...
I think this is a output scale issue for those basemaps. The scale on screen is not the same as the scale in...
Read more >
How to Adjust High-DPI Scaling in Windows 10 | Digital Trends
1. Click the Notification icon on the Taskbar and select the All Settings tile in the Action Center. Alternatively, click the Start button...
Read more >
Retina - HiDPI tiles - MapTiler Support
With MapTiler Engine you can solve this problem by setting the "HiDPI/Retina tiles" option located in the "Output settings" page. retina_1.png.
Read more >
dpi dependant scaling - Google Groups
This is already the case, the tile size is computed both from the device scale factor and the user scale factor. The user...
Read more >
High DPI images for variable pixel densities - web.dev
In practice, low density images should look the same on new screens as they did on old ones, but compared to the crisp...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found