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().
Here's some pseudo code that may help. You can get the content height and width from the webview and then you can leverage webview.draw()...so something like the following.
Bitmap bitmap = Bitmap.createBitmap( webView.getWidth(), webView.getContentHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
webView.draw(canvas);
Then you can output your bitmap file using bitmap.compress and output it to a file output stream
//fos is a FileOutputStream, you can use something else if needed.
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
The only issue I foresee with this is that your bitmap may clip the content horizontally since WebView doesn't have a method to get the content width. Otherwise I think this should work.
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();
Then as Paul said, save it through FileOutputStream
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With