View转化为bitmap

//scale为缩放倍数,例如将View变为原来的1/3大小,scale=0.3
public Bitmap viewToBitmap(View view,float scale){
    int width = (int)(view.getWidth()*scale);
    int height = (int)(view.getHeight()*scale);
    
    Bitmap bitmap = Bitmap.createBitmap(width,height,Bitmap.config.AGRB_8888);
    Canvas canvas =new Canvas(bitmap);
    view.draw(canvas);
    return bitmap;    
}
相关文章
相关标签/搜索