【发布时间】:2015-07-09 04:11:25
【问题描述】:
我正在尝试在 android 中编写一个方法来将整个 webview 保存为图像,如下所示:
bitmap = Bitmap.createBitmap(webView.getWidth(),
Math.round(webView.getContentHeight() * webView.getScale()), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
webView.draw(canvas);
FileOutputStream out = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, JPEG_COMPRESSION, out);
但是,位图太大(超过 100 MB)并且占用了太多内存。有谁知道保持低内存使用的更好方法? 问题是WebView很小,生成的JPEG文件很小,但中间的Bitmap很大,其他地方不用了。
【问题讨论】:
标签: android webview bitmap android-webview android-bitmap