Code snippet:
public Bitmap getScreenShot(int x,int y,int width,int height){View v1 = getWindow().getDecorView().getRootView();
v1.setDrawingCacheEnabled(true);
final Bitmap screenShot = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
final Bitmap cropBitmap = Bitmap.createBitmap(screenShot,x,y,width,height);
return cropBitmap.copy(cropBitmap.getConfig(),true);
}
沒有留言:
張貼留言