Created
April 14, 2019 07:51
-
-
Save twlkyao/f3bc4f7644eb2f991911ca3c6dec83e6 to your computer and use it in GitHub Desktop.
Android Create Bitmap from View
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Bitmap loadBitmapFromView(View v) { | |
int w = v.getWidth(); | |
int h = v.getHeight(); | |
Bitmap bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); | |
Canvas c = new Canvas(bmp); | |
// c.drawColor(Color.WHITE);//如果不设置canvas画布为白色,则生成透明 | |
v.layout(0, 0, w, h); | |
v.draw(c); | |
return bmp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment