Proof of Concept: Near Realtime Blur
Proof of Concept: Near Realtime Blur
I just don’t have much time currently, but there were so many requests for blur effects lately…
Maybe someone can create something useful with this.
]]>
< ![CDATA[
LL.bindClass(“android.graphics.Bitmap”);
LL.bindClass(“android.graphics.Canvas”);
LL.bindClass(“android.renderscript.RenderScript”);
LL.bindClass(“android.renderscript.Allocation”);
LL.bindClass(“android.renderscript.ScriptIntrinsicBlur”);
var d=LL.getCurrentDesktop();
var v=d.getView();
var img=LL.createImage(v.getMeasuredWidth(),v.getMeasuredHeight());
var s=d.addShortcut(“”,new Intent(),0,0);
s.getProperties().edit().setBoolean(“i.onGrid”,false).setBoolean(“s.iconVisibility”,false).commit();
s.setSize(d.getWidth(),d.getHeight());
var i=1;
var f=function(){
var bmp=Bitmap.createBitmap(v.getMeasuredWidth(),v.getMeasuredHeight(),Bitmap.Config.ARGB_8888);
var c=new Canvas(bmp);
v.draw(c);
var rs=RenderScript.create(LL.getContext());
var a=Allocation.createFromBitmap(rs,bmp);
var blur=ScriptIntrinsicBlur.create(rs,a.getElement());
blur.setInput(a);
blur.setRadius(i);
blur.forEach(a);
a.copyTo(bmp);
img.draw().drawBitmap(bmp,0,0,null);
img.update();
s.setBoxBackground(img,”nfs”);
if(i<25){
i++;
setTimeout(f,0);
}
rs.destroy();
}
f();
]]>
< ![CDATA[
Awesome, Lukas!
]]>
< ![CDATA[
Where/how would you use
this?
]]>