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

前端 未结 4 2064
眼角桃花
眼角桃花 2020-12-08 12:28

I am working in a map project in android. It contains larger image of 10000x10000 resolution. Using this image with Bitmap it gives OutOfMemoryError

4条回答
  •  天命终不由人
    2020-12-08 13:07

    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();
        }
    

提交回复
热议问题