How to blur imageview in android

后端 未结 10 1954
南笙
南笙 2020-12-05 10:54

I have an imageview and i set Image Resources programmatically like this:

int resourceId = getResources().getIdentifier(\"imagename\", \"drawable\", \"mypack         


        
相关标签:
10条回答
  • 2020-12-05 11:49

    Just simply use this library https://github.com/ChathuraHettiarachchi/BlurIM , I was having problem with BlurTransformation class had errors thats why couldn't use Glide transformation but this works fine.

    BlurImage.withContext(this)
         .blurFromResource(R.drawable.YOUR_RESOURCE)
         .into(imageView);
    
    0 讨论(0)
  • 2020-12-05 11:51

    You can use RenderScript to accomblish that as explained here or you can use the stackblur library to make a blurring effect in your image.

    Usage of the stackblur library:

    int resourceId = getResources().getIdentifier("imagename", "drawable", "mypackage");
    // get bitmap from resource id
    Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId);
    StackBlurManager stackBlurManager = new StackBlurManager(bitmap);
    // process the image using a certain radius
    stackBlurManager.process(progress*4);
    // obtain the image and load it into an ImageView or any other component
    imgLock.setImageBitmap(stackBlurManager.returnBlurredImage());
    
    0 讨论(0)
  • 2020-12-05 11:51

    There's the library that can use RenderScript so a blurring is blazingly fast and super easy to use:

    <ru.egslava.blurredview.BlurredImageView
        ...
        android:src="@drawable/..."
        app:radius="0.3"
        app:keepOriginal="true"
        app:downSampling="2" />
    
    0 讨论(0)
  • 2020-12-05 11:54

    You can use glide transformations https://github.com/wasabeef/glide-transformations you can blur the image with one line of code

    Glide.with(this).load(R.drawable.demo)
        .bitmapTransform(new BlurTransformation(context))
        .into((ImageView) findViewById(R.id.image));
    
    0 讨论(0)
提交回复
热议问题