0
I need to do a Blur effect on a background image. How can I do this?
0
I need to do a Blur effect on a background image. How can I do this?
5
Use the class Scriptintrinsicblur Android to create the effect of Blur:
Example of use, adapted from this question soen:
@SuppressLint("NewApi")
private Bitmap blurRenderScript(Bitmap smallBitmap, int blurRadius) {
Bitmap output = Bitmap.createBitmap(smallBitmap.getWidth(), smallBitmap.getHeight(), smallBitmap.getConfig());
RenderScript rs = RenderScript.create(getContext());
ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
Allocation inAlloc = Allocation.createFromBitmap(rs, smallBitmap, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_GRAPHICS_TEXTURE);
Allocation outAlloc = Allocation.createFromBitmap(rs, output);
script.setRadius(blurRadius);
script.setInput(inAlloc);
script.forEach(outAlloc);
outAlloc.copyTo(output);
rs.destroy();
MutableBitmap.delete(smallBitmap);
return output;
}
3
I use a very simple library to make these effects.
https://github.com/wasabeef/Blurry
To use it is very simple:
Add to the statement:
dependencies {
compile 'jp.wasabeef:blurry:2.0.3'
}
After you staunch the image, you set the Blur, example:
Blurry.with(this)
.radius(10)
.sampling(8)
.color(Color.argb(66, 255, 255, 0))
.async()
.animate(500)
.onto(sua_imagem);
-1
I use this paste to make the Blur in the images
I hope it helps. in git itself has been explaining how to include lib and how to run Cod, with few lines you do Blur in the images.
Browser other questions tagged android
You are not signed in. Login or sign up in order to post.
Dude you posted the same lib q I put on top -_-
– Jasar Orion
I hadn’t seen your answer, I was doing mine correctly, since you just threw a link there without any explanation. Hugs.
– Leonardo Dias