moagrius / TileView

TileView is a subclass of android.view.ViewGroup that asynchronously displays, pans and zooms tile-based images. Plugins are available for features like markers, hotspots, and path drawing.
MIT License
1.46k stars 337 forks source link

Load tiles from external storage #76

Closed derekbrameyer closed 10 years ago

derekbrameyer commented 10 years ago

Hi moagrius, thanks for the awesome work on TileView. I've built a script that downloads a large image from the web, uses ImageMagick on Android to slice it up (this takes some time, ~10-15 seconds), and saves the tiles in the external storage directory. I then try to load the tiles like so:

mTileView.setSize(mWidth, mHeight);
mTileView.addDetailView(1.0f, pathToTiles + "/%col%_%row%.png");

Attaching the debugger shows that pathToTiles is "/storage/emulated/0/Android/data/com.myapp.android/files", so it looks like it's pointing to the right directory.

Have you ever tried doing this before? Thanks for any help you can provide!

moagrius commented 10 years ago

Hi derek,

By default, TileView will try to read tiles from assets, but this is easily modified. You'll need to use a custom BitmapDecoder to read the files from the sd card... I've never done it myself but I know several other users have, and in fact users have successfully read from HTTP, SD card, or even decoded regions of a single large resource file with custom implementations.

The interface is very simple (one method that just has to return a Bitmap) - here's a quick write-up: https://github.com/moagrius/TileView/wiki/Tile-Sources

Post back if you need more help.

derekbrameyer commented 10 years ago

Agreed, incredibly easy. BitmapDecoder.decodeBitmap(filePath) was all I needed. Thanks!