When mimicking the IOS password input page, it was found to have a fuzzy background, so I learned it and recorded it for use. In Android, the following methods are implemented
The http://www.jb51.net/article/64781.htm of the Bible
private void Applyblur () {
//Get wallpaper manager
Wallpapermanager Wallpapermanager = wallpapermanager.getinstance ( This.getcontext ());
Get the current wallpaper
drawable wallpaperdrawable = wallpapermanager.getdrawable ();
Convert drawable to Bitmap
Bitmap bmp = ((bitmapdrawable) wallpaperdrawable). Getbitmap ();
Blur (BMP);
The reason for the following is to do small and big processing, because only rely on Scriptintrinsicblur to deal with the mode, can not reach the effect of the model, if you need to deepen the pattern effect of the need to reduce the background picture, after processing and then enlarged. This can be done using the matrix. , and it can shorten the blur time.
@TargetApi (build.version_codes.
JELLY_BEAN_MR1) private void Blur (Bitmap bkg) {Long Startms = System.currenttimemillis ();
float radius = 20;
bkg = Small (bkg);
Bitmap Bitmap = bkg.copy (Bkg.getconfig (), true);
Final Renderscript rs = renderscript.create (This.getcontext ()); Final allocation input = Allocation.createfrombitmap (RS, bkg, Allocation.MipmapControl.MIPMAP_NONE, Allocation.usag
E_script);
Final allocation output = allocation.createtyped (RS, Input.gettype ());
Final Scriptintrinsicblur script = Scriptintrinsicblur.create (RS, Element.u8_4 (RS));
Script.setradius (RADIUS);
Script.setinput (input);
Script.foreach (output);
Output.copyto (bitmap);
Bitmap = big (bitmap);
SetBackground (New Bitmapdrawable (Getresources (), bitmap));
Rs.destroy ();
LOG.D ("Zhangle", "Blur take Away:" + (System.currenttimemillis ()-STARTMS) + "MS");
private static Bitmap big (Bitmap Bitmap) {Matrix matrix = new Matrix (); Matrix.postScale (4f,4f);
Long and wide magnification reduces the proportion of Bitmap resizebmp = Bitmap.createbitmap (Bitmap,0,0,bitmap.getwidth (), Bitmap.getheight (), matrix,true);
return resizebmp;
private static Bitmap Small (Bitmap Bitmap) {Matrix matrix = new Matrix (); Matrix.postscale (0.25f,0.25f);
Long and wide magnification reduces the proportion of Bitmap resizebmp = Bitmap.createbitmap (Bitmap,0,0,bitmap.getwidth (), Bitmap.getheight (), matrix,true);
return resizebmp;
}