Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tile and scroll a large image (10000x10000) in android

Tags:

android

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.

like image 635
ankita gahoi Avatar asked Jan 13 '11 09:01

ankita gahoi


2 Answers

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();
    }
like image 96
Mukul Jain Avatar answered Oct 13 '22 00:10

Mukul Jain


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

like image 22
diegocarloslima Avatar answered Oct 13 '22 01:10

diegocarloslima