Search code examples
androidnetworkimageview

How to make my profile background image as darker blur


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;
    }

Solution

  • 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);