Open Dr-Emann opened 10 years ago
Hello @Dr-Emann ,
I would say the explicit option has bigger advantages rather than the implicit. We are supporting existing code, but from now on the user can also use a new feature to improve performance - in the case he was having performance problems, I do not think this will happen if they are blurring single images.
What are your thoughts?
I agree. I've set up something here: https://github.com/Dr-Emann/android-stackblur/tree/less_garbage. I'll have to clean it up a little, and submit a pull request.
Cool :-). Looking forward!
Hi guys, I'm currently experiencing Out of memory exceptions. I use your library to blur single images in separate activities, but it seems that on lower-end devices this causes out of memory exceptions after some time. I managed to reduce the exceptions by scaling down the image 3 times before I pass to the StackBlur and then scaling it back to normal, but this produces lower image quality. Do you have any progress on the issue? I'm currently using the .process(radius) method. I haven't tried the processNatively method, do you think it would make a difference?
Hello @randomrandom ,
Old and low end devices might have problems running the library. Are you running the Java method? Running the NDK or RenderScript process definitely helps in terms of optimization, but still some devices might not be able to process it.
http://developer.android.com/training/displaying-bitmaps/index.html
I fear that in that case the only solution is to reduce the image size
The Garbage Collector is being run (
GC_FOR_MALLOC
) on every blur because we're creating a new bitmap on every call. There's two ways to try to fix this.Explicit Bitmap Re-use
The usual solution to this problem is to allow the user to pass an existing bitmap in.
Pros
Cons
Implicit Bitmap Re-use
However, because we have the StackBlurManager class which already holds a reference to the result, we could possibly reuse that bitmap. This could possibly break some existing code though! If the user holds on to a reference to the blurred bitmap, then blurs again, the first reference will be modified to be the same as the second. For example:
Another possible problem arises if the user tries to recycle the image.
The StackBlurManager can check if the image has been recycled before trying to blur into it, and make a new bitmap if it has been, possibly putting something in the log letting the user know they shouldn't call recycle on bitmaps owned by the manager.
Pros
Cons