GithubHelp home page GithubHelp logo

wasabeef / blurry Goto Github PK

View Code? Open in Web Editor NEW
5.5K 102.0 604.0 2.23 MB

Blurry is an easy blur library for Android

License: Apache License 2.0

Java 89.94% Kotlin 10.06%
android android-library image-processing blur java kotlin

blurry's Introduction

Android Arsenal License Maven Central

Blurry is an easy blur library for Android.

logo

Screenshot

Demo

How do I use it?

Setup

Dependencies
repositories {
  mavenCentral()
}

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

Functions

Overlay

Parent must be ViewGroup

Blurry.with(context).radius(25).sampling(2).onto(rootView)

Into

// from View
Blurry.with(context).capture(view).into(imageView)
// from Bitmap 
Blurry.with(context).from(bitmap).into(imageView)

Blur Options

  • Radius
  • Down Sampling
  • Color Filter
  • Asynchronous Support
  • Animation (Overlay Only)
Blurry.with(context)
  .radius(10)
  .sampling(8)
  .color(Color.argb(66, 255, 255, 0))
  .async()
  .animate(500)
  .onto(rootView);

Get a bitmap directly

// Sync
val bitmap = Blurry.with(this)
  .radius(10)
  .sampling(8)
  .capture(findViewById(R.id.right_bottom)).get()
imageView.setImageDrawable(BitmapDrawable(resources, bitmap))

// Async
Blurry.with(this)
  .radius(25)
  .sampling(4)
  .color(Color.argb(66, 255, 255, 0))
  .capture(findViewById(R.id.left_bottom))
  .getAsync {
    imageView.setImageDrawable(BitmapDrawable(resources, it))
  }

Requirements

Android 5.+ (API 21)

Developed By

Daichi Furiya (Wasabeef) - [email protected]

Follow me on Twitter

License

Copyright (C) 2020 Wasabeef

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

blurry's People

Contributors

easycheese avatar jasoncromer avatar wasabeef avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blurry's Issues

ERROR: android.support.v8.renderscript.RSRuntimeException: Error loading libRSSupport library

Hi, thanks for sharing such a nice library.

I have problem with this library (latest, from github) while running on Android 4.1.1, API 16, (Sony C1605).

How can I resolve this issue?

Here is the debug output:

12-08 11:20:24.909 29458-29684/jp.wasabeef.example.blurry E/RenderScript_jni: No GC methods
12-08 11:20:24.919 29458-29684/jp.wasabeef.example.blurry V/RenderScript_jni: RS compat mode
12-08 11:20:24.939 29458-29458/jp.wasabeef.example.blurry D/Blurry: TIME 42ms
12-08 11:20:24.939 29458-29685/jp.wasabeef.example.blurry V/RenderScript_jni: RS compat mode
12-08 11:20:24.939 29458-29686/jp.wasabeef.example.blurry V/RenderScript_jni: RS compat mode
12-08 11:20:24.939 29458-29684/jp.wasabeef.example.blurry W/dalvikvm: threadid=11: thread exiting with uncaught exception (group=0x40c34498)
12-08 11:20:24.949 29458-29685/? W/dalvikvm: threadid=12: thread exiting with uncaught exception (group=0x40c34498)
12-08 11:20:24.949 29458-29684/? E/test: Exception
12-08 11:20:24.949 29458-29684/? E/AndroidRuntime: FATAL EXCEPTION: pool-1-thread-1
                                                   android.support.v8.renderscript.RSRuntimeException: Error loading libRSSupport library
                                                       at android.support.v8.renderscript.RenderScript.internalCreate(RenderScript.java:1379)
                                                       at android.support.v8.renderscript.RenderScript.create(RenderScript.java:1504)
                                                       at android.support.v8.renderscript.RenderScript.create(RenderScript.java:1454)
                                                       at android.support.v8.renderscript.RenderScript.create(RenderScript.java:1430)
                                                       at android.support.v8.renderscript.RenderScript.create(RenderScript.java:1417)
                                                       at jp.wasabeef.blurry.internal.Blur.rs(Blur.java:62)
                                                       at jp.wasabeef.blurry.internal.BlurTask$1.run(BlurTask.java:60)
                                                       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
                                                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
                                                       at java.lang.Thread.run(Thread.java:856)

build error Duplicate files "armeabi-v7a/librsjni.so"

Error:duplicate files during packaging of APK E:\MyAndroidSudioProgects\ChongBaoFunny\demo\build\outputs\apk\demo-debug-unaligned.apk
Path in archive: lib/armeabi-v7a/librsjni.so
Origin 1: E:\MyAndroidSudioProgects\ChongBaoFunny\demo\build\intermediates\exploded-aar\jp.wasabeef\blurry\1.0.5\jni\armeabi-v7a\librsjni.so
Origin 2: D:\work\AndroidSDK\build-tools\22.0.1\renderscript\lib\packaged\armeabi-v7a\librsjni.so
You can ignore those files in your build.gradle:
android {
packagingOptions {
exclude 'lib/armeabi-v7a/librsjni.so'
}
}
Error:Execution failed for task ':demo:packageDebug'.

Duplicate files copied in APK lib/armeabi-v7a/librsjni.so
File 1: E:\MyAndroidSudioProgects\ChongBaoFunny\demo\build\intermediates\exploded-aar\jp.wasabeef\blurry\1.0.5\jni\armeabi-v7a\librsjni.so
File 2: D:\work\AndroidSDK\build-tools\22.0.1\renderscript\lib\packaged\armeabi-v7a\librsjni.so

I have added
packagingOptions {
exclude 'lib/armeabi-v7a/librsjni.so'
}
in my build.gradle but it still report this error

Fatal Exception: java.lang.NullPointerException

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isRecycled()' on a null object reference
at android.graphics.Canvas.throwIfCannotDraw(Canvas.java:1302)
at android.graphics.Canvas.drawBitmap(Canvas.java:1358)
at jp.wasabeef.blurry.internal.Blur.rs(Blur.java:60)
at jp.wasabeef.blurry.internal.BlurTask$1.run(BlurTask.java:60)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)

use blurry inside listView

hi i use your blurry .... but part of list not blurred
it's my code ... i would items>=2 blurred but some one not blurred

    final View finalConvertView = convertView;
    final ViewHolder finalHolder = holder;

    if (pos >= 2) {

        finalConvertView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                finalHolder.blurView.setVisibility(View.GONE);
                Blurry.with(context)
                        .radius(3)
                        .sampling(3)
                        .capture(finalConvertView)
                        .into(finalHolder.blurView);
                finalHolder.blurView.setVisibility(View.VISIBLE);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    finalConvertView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                } else {
                    finalConvertView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                }
            }
        });

    } else {
        finalHolder.blurView.setVisibility(View.GONE);
        finalHolder.blurView.setImageBitmap(null);
    }

Example of less impact in performance

Hi!

First, congratulations for your library!
Please, may you provide some example of which configuration would be the best for performance?
I have a recycler view and depending on some conditions I blur the ImageView of each item. I'm worried about the impact in performance when scrolling.

Thanks in advance!

async() throws RuntimeException

I am using the below code for blurring which is working fine for me.

    Blurry.with(MainActivity.this)
                        .radius(25)
                        .sampling(2)
                        .onto((ViewGroup) findViewById(R.id.content));

but if I use the Async mode it throws RuntimeException

Blurry.with(MainActivity.this)
.radius(25)
.sampling(2)
.async()
.animate(500)
.onto((ViewGroup) findViewById(R.id.content));

Out of memory exception

Fatal Exception: java.lang.OutOfMemoryError: Failed to allocate a 5529612 byte allocation with 2175304 free bytes and 2MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(VMRuntime.java)
at android.graphics.Bitmap.nativeCreate(Bitmap.java)
at android.graphics.Bitmap.createBitmap(Bitmap.java:975)
at android.graphics.Bitmap.createBitmap(Bitmap.java:946)
at android.graphics.Bitmap.createBitmap(Bitmap.java:913)
at jp.wasabeef.blurry.internal.Blur.rs(Blur.java:51)
at jp.wasabeef.blurry.internal.BlurTask$1.run(BlurTask.java:60)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)

Any help for this ?
Thanks

Caching

Hi, I wanna ask if is there any way how to cache blurred images... For example i want to use blurred image from previous screen instead of new blurring or when screen was rotated.

Thanks for response and thanks for amazing library.

java.lang.VerifyError: jp/wasabeef/blurry/internal/Blur

Error:

java.lang.VerifyError: jp/wasabeef/blurry/internal/Blur
                                                     at jp.wasabeef.blurry.Blurry$Composer.onto(Blurry.java:115)

the Blurry.java:115 is
Drawable drawable = new BitmapDrawable(context.getResources(), Blur.rs(target, factor));

my build.gradle is

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.1'

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        renderscriptTargetApi 23
        renderscriptSupportModeEnabled true
    }

Crash using on Oncreate

It crash using it into onCreate. I solved using a hendler like
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@OverRide
public void run() {
//Do something after 1000ms
Blurry.with(getApplicationContext()).capture(m_Cover).into((ImageView) findViewById(R.id.dash_imageView_cover_to_blurry));
}
}, 150);

Are there any solution to have blur effect without delay?

Imageview larger than screen size

Hi,

This is an excellent library and very much thankful for the same. I have been using this library for some time now and i have noticed that when the imageview is larger than the screen, it dosen't generate a blurred output. I'm using a simple code

Blurry.with(getContext()).radius(10).sampling(8).async().capture(imageView).into(imageView);

My imageView is larger than the view area in the screen and i have kept it like that. No error is shown, but the imageView becomes blank. I also had problem getting the drawing cache for the view. What i did was

`public Bitmap loadBitmapFromView(View v) {

    int width = v.getLayoutParams().width;
    int height = v.getLayoutParams().height;
    Bitmap b = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(b);
    v.layout((int) ((float) screenWidth * -0.2f), 0, width, height);
    v.draw(c);
    return b;

}`

This solved my drawingcache problem. So what has gone wrong with the blur. What should i do to get the blurred output.

OutOfMemoryError

e: FATAL EXCEPTION: pool-10-thread-1
Process: com.ks.kaishustory, PID: 23125
java.lang.OutOfMemoryError
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:903)
at android.graphics.Bitmap.createBitmap(Bitmap.java:880)
at android.graphics.Bitmap.createBitmap(Bitmap.java:812)
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:686)
at jp.wasabeef.blurry.internal.Blur.of(Blur.java:78)
at jp.wasabeef.blurry.internal.BlurTask$1.run(BlurTask.java:61)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)

Bitmap blurring

Hi,

First of all, its an awesome library and it does work really well. I was hoping if there would be a way to pass a bitmap and return a blured bitmap in the current implementation without using any views. It would be great if you can add the functionality in future.

java.lang.OutOfMemoryError

java.lang.OutOfMemoryError: Failed to allocate a 14745612 byte allocation with 13108268 free bytes and 12MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:812)
at android.graphics.Bitmap.createBitmap(Bitmap.java:789)
at android.graphics.Bitmap.createBitmap(Bitmap.java:720)
at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:596)
at jp.wasabeef.blurry.internal.Blur.of(Blur.java:78)
at jp.wasabeef.blurry.internal.Blur.of(Blur.java:41)
at jp.wasabeef.blurry.Blurry$Composer.onto(Blurry.java:121)

does any one have a solution?

Getting Fatal error randomly: (see comment for error details)

Error: A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x98c7202c in tid 5202 (pool-2-thread-2)

Here is the only code im executing using this library:

Blurry.with(getActivity()).radius(10).async().capture(mainContainerView).into(blurImage);

where mainContainerView is a linearlayout which wraps my listview in my activity. and blurImage is an ImageView in the fragment that I'm displaying on top of my listview.

The blur works fine but occasionally the app crashes with the error listed above.

If you could add error handling to catch this that would be much appreciated.

I did some research on this error and found this SO post.

See the answer by "David Walton" he might be onto something.

Thanks

NullPointerException

I'm using this in onCreate and getting crash.

MainActivity.java
ViewGroup viewGroup = (ViewGroup) findViewById(R.id.nav); Blurry.with(this).radius(25).sampling(2).onto(viewGroup);

activity_main.xml
<LinearLayout android:id="@+id/nav" android:alpha="0.95" android:layout_width="@dimen/navi_width" android:layout_height="match_parent" android:orientation="vertical" android:layout_gravity="start" android:layout_marginTop="@dimen/tab_height" android:background="@drawable/navigation" />

LogCat
08-31 15:04:31.126 25687-25687/de.test.demo E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{de.test.demo/de.test.demo.MainActivity}: java.lang.NullPointerException at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2255) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2309) at android.app.ActivityThread.access$700(ActivityThread.java:157) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1289) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:176) at android.app.ActivityThread.main(ActivityThread.java:5317) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at jp.wasabeef.blurry.internal.Blur.rs(Blur.java:38) at jp.wasabeef.blurry.Blurry$Composer.onto(Blurry.java:107) at de.test.demo.MainActivity.onCreate(MainActivity.java:120) at android.app.Activity.performCreate(Activity.java:5326) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2218)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2309)             at android.app.ActivityThread.access$700(ActivityThread.java:157)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1289)             at android.os.Handler.dispatchMessage(Handler.java:99)             at android.os.Looper.loop(Looper.java:176)             at android.app.ActivityThread.main(ActivityThread.java:5317)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:511)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)             at dalvik.system.NativeStart.main(Native Method)

starting work only after second call

Call

Blurry.with(getActivity())
                    .radius(5)
                    .sampling(2)
                    .color(Color.argb(66, 0, 0, 0))
                    .async()
                    .animate(500)
                    .onto(linearLayout);

in fragment, on click. Blurring happens only after second click.
CatLog says:

V/RenderScript: 0x780f4d68 Launching thread(s), CPUs 4
E/RenderScript: Successfully loaded runtime: libRSDriver_adreno.so

on each click. but nothing happens at first click. Why is it so?
OS: kitkat 4.4.4

not work

Hello

my code :

Blurry.with(GameStart.this)
            .radius(25)
            .sampling(2)
            .async()
            .animate(500)
            .onto((ViewGroup) findViewById(R.id.game_start));

the problem is nothing is blurred , so i tried to blur a specific layout in this view and this is the result : img

so it's seems that the library is work but the problem it's just adding another blured view and not delete the old one !

Details on how to use this with maven

Hello,

as I spent a couple of hours trying to set up this with the android maven plugin, I think that it will be useful to many to add the following instructions:

  1. You will need the renderscript jar file. This resides in <ANDROID_HOME>\build-tools\renderscript\lib. I went for the latest version, 23.0.0 at the moment of writing this.
  2. You can either install it in your local .m2 directory, or upload it to a nexus repository server

I added it as

<dependency>
     <groupId>com.android.support</groupId>
     <artifactId>renderscript-v8</artifactId>
     <version>23.0.0</version>
</dependency>
  1. You need to add the native libs in your apk. These can be found under <ANDROID_HOME>\build-tools\renderscript\lib\packaged. Just copy all folders contained in the "packaged" folder to a location in your project (e.g. in a folder called native-libs) and then add the following line in the android-maven-plugin configuration, in your pom.xml:
<nativeLibrariesDirectory>${project.basedir}/native-libs</nativeLibrariesDirectory>

You can verify that the native libs have been included in the build by checking the build for the following text :

[INFO] Adding native libraries: ...

That's all !

What targetSdk is needed to use this?

Im targeting 23 with build tools at 23.0.2 and trying to run the example in the README, but getting a gradle build error:

Error:duplicate files during packaging of APK

What could be causing this?

failed to fetch blurry:0.0.3

Hello, I get the following message when trying to compile it:

Error:(63, 13) Failed to resolve: jp.wasabeef:blurry:0.0.3 <a href="openFile">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>

Crash using adapters

Hi!

I had a crash while using adapters

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.Bitmap.recycle()' on a null object reference
at jp.wasabeef.blurry.internal.Blur.of(Blur.java:42)
at jp.wasabeef.blurry.Blurry$ImageComposer.into(Blurry.java:163)
at org.parley.models.common.base.BaseViewCell.onBindViewHolder(BaseViewCell.java:487)

I don't know if you are calling recycler() while reload data

Reverse mode

Is it possible to use this library in reverse mode? From blur to high definition?

My Fragement can't show it

Blurry.with(getActivity())
.radius(25)
.sampling(1)
.color(Color.argb(66, 255, 255, 0))
.async()
.capture(gg)
.into(gg);
gg is a ImageView, use it show nothing in my appliacation,have can i do ?

LinearLayout Blur Problem

Hi,
My root view is a linear layout.When apply blur effect for this layout like below, it is not working

       Blurry.with(MainFragmentActivity.this)
                            .radius(25)
                            .sampling(2)
                            .async()
                            .animate(500)
                            .onto((ViewGroup) findViewById(R.id.content));

But when i changed root view type as RelativeLayout, it is working.How to apply blur effect for LinearLayout ?

Crash

java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isRecycled()' on a null object reference
at android.graphics.Canvas.throwIfCannotDraw(Canvas.java:1224)
at android.graphics.Canvas.drawBitmap(Canvas.java:1280)
at jp.wasabeef.blurry.internal.Blur.rs(Blur.java:52)
at jp.wasabeef.blurry.internal.BlurTask.doInBackground(BlurTask.java:58)
at jp.wasabeef.blurry.internal.BlurTask.doInBackground(BlurTask.java:27)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)

NullPointerException: Attempt to invoke virtual method 'void android.graphics.Bitmap.recycle()' on a null object reference

I'm getting the following err:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.Bitmap.recycle()' on a null object reference
       at jp.wasabeef.blurry.internal.Blur.of(SourceFile:42)
       at jp.wasabeef.blurry.Blurry$Composer.onto(SourceFile:115)
       ...................

...while calling the following:

Blurry.with(activity)
    .radius(40)
    .sampling(2)
    .color(ResourcesUtil.getColor(R.color.dirtyBlack25))
    .onto(blurredView);

As far as I understood, the err occurs here inside of method of Blur class:

Bitmap cache = view.getDrawingCache();
cache.recycle();

Here, the drawing cache can be null sometimes. This err occurs rarely. However, could you please solve this and update the library accordingly?

Blurry not working in onCreate?

Hi wasabeef, i really like blurry library, but i had a problem with this.
When i set Blurry(..) in OnCreate method then it not working ?

@OverRide
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getId();//get id of rela_Background
init();
Blurry.with(context)
.radius(25)
.sampling(6)
.async()
.animate(500)
.onto(rela_Background);
}

How to blur "rela_Background" when open app .

How to use blurry inside a listview

While using blurry in a listview its give me error, please show implemetation if we can use use blurry inside a listview to blur images in a list

how to import as a module?

I try to import as a module but fail.IDE always report Unable to save plugin settings: The plugin org.jetbrains.android failed to save settings and has been disabled. Please restart Android Studio

How to avoid blurring textviews over constraint layout?

screen shot 2017-05-12 at 1 07 06 pm
I am trying to blur a constraint layout, which has edit text fields and text views inside of it.

But when I blur the layout, it blurs over everything else.

I made my text fields in xml.

This is my code.

`rlSignUpLogin.post(new Runnable() {

        @Override
        public void run() {
            Blurry.with(sign_up.this)
                    .radius(25)
                    .sampling(2)
                    .animate(500)
                    .onto((ViewGroup) findViewById(R.id.cl_signup_login_box));
        }
    });`

bug

error log:
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:304)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v8/renderscript/RenderScript;
at jp.wasabeef.blurry.internal.Blur.rs(Blur.java:56)
at jp.wasabeef.blurry.internal.BlurTask.doInBackground(BlurTask.java:58)
at jp.wasabeef.blurry.internal.BlurTask.doInBackground(BlurTask.java:27)
at android.os.AsyncTask$2.call(AsyncTask.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v8.renderscript.RenderScript" on path: DexPathList[[zip file "/data/app/com.brucewuu.android.mdog-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
            at jp.wasabeef.blurry.internal.Blur.rs(Blur.java:56)
            at jp.wasabeef.blurry.internal.BlurTask.doInBackground(BlurTask.java:58)
            at jp.wasabeef.blurry.internal.BlurTask.doInBackground(BlurTask.java:27)
            at android.os.AsyncTask$2.call(AsyncTask.java:292)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:818)
Suppressed: java.lang.ClassNotFoundException: android.support.v8.renderscript.RenderScript
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 10 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

Blurry.delete().animate()?

Is there any way to remove the blur via an animation? Currently it seems Blurry.delete(ViewGroup) is all that exists.

I can use animateLayoutChanges=true on the rootview but as I'm using a DrawerLayout this also animates the Navigation drawer which I would like to avoid.

Doesn't work with webviews

I was planning on using this to blur the entire activity while a dialog pops up. However, getting the drawable cache returns the section at the very top of the webview, not the portion that is currently visible. When blurring, I was using the decor view as a target

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.