2

我有一个 webview,我像这样捕获视图

    Picture picture = m_browser.capturePicture();
    Bitmap  b = Bitmap.createBitmap( picture.getWidth(),
                picture.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas( b );
    picture.draw( c );
    FileOutputStream fos = null;

    try {
        fos = new FileOutputStream("/sdcard/temp_1.jpg");
        //fos = openFileOutput("samsp_1.jpg", MODE_WORLD_WRITEABLE);
        if ( fos != null )
        {
            b.compress(Bitmap.CompressFormat.JPEG,90, fos);  
            fos.close();
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();

    }
}

现在,如果加载的网站很长,例如。times.com 那么这张图片也太大了。

我想将此图像拆分为多个图像并且不降低质量。

我想以尽可能高的质量获得这些图像。

请。帮助 谢谢

4

2 回答 2

1

这有点骇人听闻,但这将适用于非常长的网页而不会耗尽内存。首先,将您的 webview 放在另一个布局中(RelativeLayout rl)。根据您想要的图像大小调整RelativeLayout。然后调用:

rl.draw(canvas);
// do something here to save your bitmap
webview.scrollby(0, rl.getHeight());

并重复此操作,直到您位于页面底部!

于 2011-09-16T06:44:39.990 回答
0
Bitmap.createBitmap(source, x, y, width, height)

I allways use this code to cut the a large image to multiple images.

I can use it easy

于 2011-04-28T11:43:46.853 回答