使用人行横道显示网页时,如何将整个视图捕获到位图中? [英] How can I capture the whole view into a Bitmap when using crosswalk to display webpage?

查看:88
本文介绍了使用人行横道显示网页时,如何将整个视图捕获到位图中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用CrossWalk显示网页,效果很好。我具有将全部内容捕获为位图以保存到SDCard的功能,但是找不到解决方案。使用TextureView只能捕获屏幕大小的位图,有人遇到同样的问题吗?顺便说一句,我可以使用WebView.draw()捕获全部内容。

I use CrossWalk to display webpage, it works well. I have a feature to capture the whole content as bitmap to save into SDCard, but I cannot found a solution. Using TextureView can only capture a screen size bitmap, anyone has the same issue? BTW, I can capture the whole content using WebView.draw().

推荐答案

我以前从未使用过人行横道,但是我猜测Crosswalk WebView也是android.view.View的后代。如果是这样,那么您可以使用android视图绘图缓存。看起来像这样

I never using crosswalk before, but I'm guessing the Crosswalk WebView is also descendant from android.view.View. If so, then you could use android view drawing cache. It look like this

yourWebView.setDrawingCacheEnabled(true);
Bitmap bmp = yourWebView.getDrawingCache();

然后如Paul所说,通过FileOutputStream保存它

Then as Paul said, save it through FileOutputStream

bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);

这篇关于使用人行横道显示网页时,如何将整个视图捕获到位图中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆