1

I am trying to make my image as darker blur.How can I do that darker blur?

I am making my image as blur ,working fine but that one not darker.That too I am using Network image view,my images are dynamic coming from service api. How can I make my images darker blur.

Thanks in advance.

I am using the below code.

 public static Bitmap blur(Context ctx, Bitmap image) {
        int width = Math.round(image.getWidth() * BITMAP_SCALE);
        int height = Math.round(image.getHeight() * BITMAP_SCALE);

        Bitmap inputBitmap = Bitmap.createScaledBitmap(image, width, height, false);
        Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap);

        RenderScript rs = RenderScript.create(ctx);
        ScriptIntrinsicBlur theIntrinsic = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
        Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap);
        Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap);
        theIntrinsic.setRadius(BLUR_RADIUS);
        theIntrinsic.setInput(tmpIn);
        theIntrinsic.forEach(tmpOut);
        tmpOut.copyTo(outputBitmap);

        return outputBitmap;
    }
Charuක
  • 12,953
  • 5
  • 50
  • 88
m.v.n.kalyani
  • 760
  • 7
  • 20

1 Answers1

2

you can use setColorFilter

imageView =(ImageView) findViewById(R.id.image_view) ;
imageView.getDrawable().setColorFilter(0x76ffffff, PorterDuff.Mode.MULTIPLY );

average black color 0xff555555

Check my answer here

or you might like to work with this github project https://github.com/wasabeef/Blurry

Blurry.with(context)
  .radius(10)
  .sampling(8)
  .color(Color.argb(66, 255, 255, 0))
  .async()
  .onto(rootView);
Community
  • 1
  • 1
Charuක
  • 12,953
  • 5
  • 50
  • 88
  • then how to make it as blur? – m.v.n.kalyani Mar 11 '17 at 05:25
  • make it blur as you did, you said you did that , and get the image view and appy this , if you have no idea to blur get an idea from this question http://stackoverflow.com/questions/40421723/alertdialog-with-blur-background-in-possition-center you can use the same class called BlurView – Charuක Mar 11 '17 at 05:30
  • one more doubt after cli cking image i want to apply darker blur if i disable that i want my previous image with out dark.How can i – m.v.n.kalyani Mar 11 '17 at 05:34
  • Simple you said you take the image from server so you have the url right so just reset the image to the view if it gets clicked you can apply blur and dark effect again also check the given library it may help you for a quick workout – Charuක Mar 11 '17 at 05:38
  • tha t one ok.now i will do that after click on image.if i gain deselect that image how do i remove black color this setColorFilter(0x76ffffff, PorterDuff.Mode.MULTIPLY ); – m.v.n.kalyani Mar 11 '17 at 05:42
  • You can call `clearColorFilter()` for the same object on which you called `setColorFilter()`. This method is equivalent to `setColorFilter(null)` it will remove the filter – Charuක Mar 11 '17 at 05:43
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/137809/discussion-between-m-v-n-kalyani-and-charu). – m.v.n.kalyani Mar 11 '17 at 05:46