Reputation: 7782
I would like to take a screenshot of my WebView, then crop it at x,y,w,h. Here is what I got:
private WebView mWebView;
public void onSavePhoto(int top, int left, int width, int height){
Bitmap bitmap = Bitmap.createBitmap(mWebView.getWidth(), mWebView.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
mWebView.draw(canvas);
}
Upvotes: 1
Views: 705
Reputation: 24417
Crop using createBitmap
private WebView mWebView;
public void onSavePhoto(int top, int left, int width, int height){
Bitmap bitmap = Bitmap.createBitmap(mWebView.getWidth(), mWebView.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
mWebView.draw(canvas);
// crop bitmap:
Bitmap croppedBitmap = Bitmap.createBitmap(bitmap, left, top, width, height);
}
Upvotes: 2
Reputation: 15379
You can do this with these steps
Upvotes: 0