I am working in a map project in android. It contains larger image of 10000x10000 resolution. Using this image with Bitmap
it gives OutOfMemoryError
. So I want to tile and scroll this image. When I scroll image, only visible screen must have tiles and other invisible tiles must be recycled. I spent lots of time but didn't find anything.
Any help will be appreciated. Provide me better solutions or idea.
as per Dave's recommendation, you can split the image into 1600 parts of 250x250px each. Photoshop does this easily in less than a minute (here). You don't have to worry about writing the html yourself too. Once you have the html (lets call it bigimage.html) and the images folder, place both these in your assets folder and access them this way -
setContentView(webView);
try {
webView.loadUrl("file:///android_asset/bigimage.html";
webView.getSettings().setLoadsImagesAutomatically(true);
} catch (Exception e) {
e.printStackTrace();
}
Starting from API level 10, you can use BitmapRegionDecoder
to load specific regions from an image without the need of manually generating the tile images. I've recently developed a lib that provides the visualisation of large images with touch gesture handling. The source code and samples are available at https://github.com/diegocarloslima/ByakuGallery
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With