1.获取前一个Activity的界面
2.将获取到的界面转化为Bitmap
3.去掉标题栏和状态栏
4.将Bitmap传递到后一个Activity中(Bitma过大,需转化为String或者byte[]传递)
5.设置背景
private Bitmap applyBlur() {
View view = getWindow().getDecorView();
view.setDrawingCacheEnabled(true);
view.buildDrawingCache(true);
/**
* 获取当前窗口快照,相当于截屏
*/
Bitmap bmp1 = view.getDrawingCache();
int height = getOtherHeight();
/**
* 除去状态栏和标题栏
*/
Bitmap bmp2 = Bitmap.createBitmap(bmp1, 0, height, bmp1.getWidth(),
bmp1.getHeight() - height);
return bmp2;
}
Bitmap bitmap = applyBlur();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.PNG, 50,baos);
String imageBase64 = new String (Base64.encode(baos.toByteArray(), 0));
intent = new Intent(this, MusicSearchActivity.class);
intent.putExtra("bitmap", imageBase64);
startActivity(intent);
String imageBase64 = getIntent().getStringExtra("bitmap");
byte[] byte64 = Base64.decode(imageBase64, 0);
ByteArrayInputStream bais = new ByteArrayInputStream(byte64);
bitmap = BitmapFactory.decodeStream(bais);
private void blur(Bitmap bkg, View view) {
long startMs = System.currentTimeMillis();
float scaleFactor = 8;// 图片缩放比例&