[英]How to crop a WebView screen capture?
我想截取WebView的屏幕截圖,然后將其裁剪為x,y,w,h。 這是我得到的:
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);
}
使用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);
}
您可以按照以下步驟進行操作
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.