Effect Blur on image [closed]

0

I need to do a Blur effect on a background image. How can I do this?

    
asked by anonymous 09.09.2016 / 19:09

3 answers

5

Use the Android ScriptIntrinsicBlur class to create the blur effect in>:

Use example, adapted from this question from the 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;
}
    
09.09.2016 / 19:23
3

I use a very simple library to make these effects.

link

To use it is very simple:

Add dependency:

dependencies {
    compile 'jp.wasabeef:blurry:2.0.3'
}

After you have stashed the image, you define Blur, for example:

Blurry.with(this)
                .radius(10)
                .sampling(8)
                .color(Color.argb(66, 255, 255, 0))
                .async()
                .animate(500)
                .onto(sua_imagem);
    
09.09.2016 / 19:19
-1

I use this paste to blur the images

Blurry Efect

Hope it helps. in git itself comes explaining how to include the lib and how to run the cod, with few lines you blur in the images.

    
09.09.2016 / 19:14