1

I add this dependence in build.gradle to blur my imageView :

dependencies {
    implementation 'com.jackandphantom.android:blurimage:1.2.0'
}

And the following code in my MainActivity.java :

    bgImage = (ImageView) findViewById(R.id.imageView);
   Bitmap bitmap = BlurImage.with(getApplicationContext()).load(R.drawable.profilbackground).intensity(25).getImageBlur();
    bgImage.setImageBitmap(bitmap);

the problem is this way is just blur to 25 radius and I want it up to 50 or 100. So, how can I change the radius blur of my image view? Please give me a way which does this.

Markus Kauppinen
  • 3,025
  • 4
  • 20
  • 30
Lina
  • 553
  • 10
  • 34

3 Answers3

4

As per the documentation it says like

This library has different methods which you can use to maintain your image blur.

   BlurImage.with(getApplicationContext()).load(R.drawable.myImage).intensity(20).Async(true).into(imageView);

OR

BlurImage.with(getApplicationContext()).load(bitmap_Image).intensity(20).Async(true).into(imageView);

method(intesity):- intensity( int value)

{ Increase Blur and limit of value is in between 0 to 25 }

The maximum limit is 25, if you want to change the value, you need to fork that and work out on that feature by yourself, or request the author of the library.

I will tell you a work around for that,

  • Scale the image down by a factor of 7
  • Run the blur again with 25
  • Scale back the image to original size
Manoj Perumarath
  • 9,337
  • 8
  • 56
  • 77
  • yes i know the max value is 25, but i want it 50 or 100. would you tell me if there isanother method to get the result what i want – Lina Apr 08 '19 at 09:42
  • I understand you very well and thank you for your reply, but i just ask you if there's another solution to blur my imageView with the radius more than 50, i mean a dependencies other than com.jackandphantom.android:blurimage:1.2.0 – Lina Apr 08 '19 at 10:16
  • @MimiSoftware Please check my udpated answer – Manoj Perumarath Apr 08 '19 at 10:41
  • 1
    Thank you very much, my problem is solved now, i use this dependence implementation 'jp.wasabeef:glide-transformations:4.0.0' which it is available url github.com/wasabeef/glide-transformations – Lina Apr 08 '19 at 10:58
  • Welcome bro happy coding :) – Manoj Perumarath Apr 08 '19 at 11:09
0

Easy Blur implementation using Glide:

dependencies {

       implementation 'com.github.bumptech.glide:glide:3.7.0'
}

In your Activity/Fragment

Glide.with(getActivity()).load(loginDetails.getUserdetail().getImage()).asBitmap().into(new SimpleTarget<Bitmap>() {
            @Override
            public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                profileImageView.setImageBitmap(BlurImageView.blur(resource));
            }
        });

BlurImageView.java

public class BlurImageView {
    private static final float BITMAP_SCALE = 0.4f;
    private static final float BLUR_RADIUS = 25f;

    public static Bitmap blur(Bitmap bitmap) {
        Bitmap u8_4Bitmap;
        if (bitmap.getConfig() == Bitmap.Config.ARGB_8888) {
            u8_4Bitmap = bitmap;
        } else {
            u8_4Bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
        }
        int width = Math.round(u8_4Bitmap.getWidth() * BITMAP_SCALE);
        int height = Math.round(u8_4Bitmap.getHeight() * BITMAP_SCALE);
        Bitmap inputBitmap = Bitmap.createScaledBitmap(u8_4Bitmap, width, height, false);
        Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap);
        RenderScript rs = RenderScript.create(UpasargaApplication.getAppContext());
        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;

    }
}
iamnaran
  • 1,894
  • 2
  • 15
  • 24
0

implementation 'com.squareup.picasso:picasso:2.5.2'

<ImageView
    android:id="@+id/iv_profilepic"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
     android:src="@mipmap/ic_launcher"/>

Target target = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {        imageViewBackground.setImageBitmap(BlurImage.fastblur(bitmap, 1f, BLUR_PRECENTAGE));
    }
    @Override
    public void onBitmapFailed(Drawable errorDrawable) {
        imageViewBackground.setImageResource(R.mipmap.ic_launcher);
    }
    @Override
    public void onPrepareLoad(Drawable placeHolderDrawable) {

    }
};