Realtime blur

Realtime blur

This is just a demo, it contains hardcoded item id etc.

Feel free to use it for whatever you can do with it.

If you want to modify it: f is the downscale factor, b is the blur radius.

By the way: This was recorded with Android studio. If you have a pc, this is a convenient way to record android videos on all 4.0+ devices.

]]>

10 Commentsto Realtime blur

  1. Anonymous says:

    < ![CDATA[

    LL.bindClass(“android.graphics.Bitmap”);


    LL.bindClass(“android.graphics.Canvas”);


    LL.bindClass(“android.renderscript.RenderScript”);


    LL.bindClass(“android.renderscript.Element”);


    LL.bindClass(“android.renderscript.ScriptIntrinsicBlur”);


    LL.bindClass(“android.renderscript.Allocation”);



    var f=2;


    var b=10;


    var d=LL.getCurrentDesktop();


    var i=d.getItemById(0x040026);


    var w=d.getWidth();


    var h=d.getHeight();


    if(typeof rs==”undefined”||rs==null){


    rs=RenderScript.create(LL.getContext());


    blur=ScriptIntrinsicBlur.create(rs,Element.U8_4(rs));


    blur.setRadius(b);


    sw=w/f;


    sh=h/f;


    orig=Bitmap.createBitmap(sw,sh,Bitmap.Config.ARGB_8888);


    bmp=Bitmap.createBitmap(sw,sh,Bitmap.Config.ARGB_8888);


    canvas=new Canvas(orig);


    canvas.scale(1/f,1/f);


    alin=Allocation.createFromBitmap(rs,orig,Allocation.MipmapControl.MIPMAP_NONE,Allocation.USAGE_SCRIPT);


    alout=Allocation.createTyped(rs,alin.getType());


    }


    bmp.eraseColor(Color.TRANSPARENT);


    orig.eraseColor(Color.TRANSPARENT);


    var items=d.getItems();


    var x=d.getPositionX();


    var y=d.getPositionY();


    for(var z=0;z


    var item=items.getAt(z);


    if(item==i)continue;


    var ix=item.getPositionX();


    var iy=item.getPositionY();


    var iw=item.getWidth();


    var ih=item.getHeight();


    var pin=item.getProperties().getString(“i.pinMode”);


    if(pin.indexOf(“X”)!=-1)ix+=x;


    if(pin.indexOf(“Y”)!=-1)iy+=y;


    if(ix-x< =w&&ix+iw-x>=0&&iy-y< =h&&iy+ih-y>=0){


    canvas.save();


    canvas.translate(ix-x,iy-y);


    item.getRootView().draw(canvas);


    canvas.restore();


    }


    }


    alin.copyFrom(orig);


    blur.setInput(alin);


    blur.forEach(alout);


    alout.copyTo(bmp);


    var img=LL.createImage(sw,sh);


    img.draw().drawBitmap(bmp,0,0,null);


    img.update();


    i.setBoxBackground(img,”nfs”);

    ]]>

  2. Anonymous says:

    < ![CDATA[

    It’s a small script… but impressive!

    ]]>

  3. Anonymous says:

    < ![CDATA[

    Pierre Hébert


    is there a way to include the wallpaper? Like draw from wallpaperview to canvas?

    ]]>

  4. Anonymous says:

    < ![CDATA[

    thanks for the script! playing around with it, and it seems to read the invisible items on the desktop. can it be modified to read only the visible items?



    how do you get the real time effect … it seems to “remember” past background images for me rather the most recent/current background



    note: i tried running the script on item resume, but can’t get it to be real time. should i be putting the entire script into a function and using settimeout instead?

    ]]>

  5. Anonymous says:

    < ![CDATA[

    Wern-Yuen Tan


     run it in position changed of the desktop. I haven’t thought about invisible items, because I don’t have them… but that should be easy to do.

    ]]>

  6. Anonymous says:

    < ![CDATA[

    Lukas Morawietz thanks, position changed worked perfectly!


    can you point me in the right direction on how to exclude the invisible items? add a criteria in the “for” loop for z items?

    ]]>

  7. Anonymous says:

    < ![CDATA[

    Lukas Morawietz this is difficult. For static system wallpaper you can use WallpaperManager.peekDrawable but there is no way with LWP (for security reasons)

    ]]>

  8. Anonymous says:

    < ![CDATA[

    Pierre Hébert and if I have a static wallpaper, can I get the scroll position of it?

    ]]>

  9. Anonymous says:

    < ![CDATA[

    Awesome! 😉

    ]]>

  10. Anonymous says:

    < ![CDATA[

    Lukas Morawietz no, the launcher provides “offsets” but it is up to the android framework to compute the actual translation (and scale). I have seen manufacturers tuning this computation making the detection of actual scroll values unreliable.

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *