0

I've been fiddling around with RenderBlur on an image for my login screen, i've gotten everything to work with a runnable() and a delay to blur the image immediately, however i'm trying to make it a slow blur while the username and password fields come into view.

I've had a bit of a look around (could be looking in the wrong places) but I haven't found anything related to what i'm after. I've attempted to use a while loop and have a blurradius value increment with a delay afterwards and send to the blurBitmap class method, but it either still blurs it immediately (meaning I probably messed something up somewhere and will most likely keep trying with this method until a better solution is found).. or it crashes.

Does anyone know if, in the first place this is possible with RenderScript? And if so, what should I be searching for.

Thanks for any help you can provide.

Resources: https://futurestud.io/blog/how-to-use-the-renderscript-support-library-with-gradle-based-android-projects

Andrew.K
  • 1
  • 1

2 Answers2

2

You can do this with RenderScript, though how you are doing it now doesn't sound like a good idea. Look into using a custom Animator which you can then run a RS blur against the image. Using Animator will be more flexible in the long run and automatically ties in with the view system rather than requiring you to handle View or Activity state explicitly.

The approach @JasonWihardja outlined will also work, but again I would suggest doing this in an Animator or similar mechanism.

Larry Schiefer
  • 15,687
  • 2
  • 27
  • 33
  • I was hoping there was some sort of animation feature, i'll look into this further and pray I can figure it out :P – Andrew.K May 19 '16 at 02:38
  • You may find this article helpful to get started with `Animator` objects: http://hiqes.com/android-animations-pt2/ – Larry Schiefer May 19 '16 at 04:21
1

Blurring an image repeatedly might cause some performance issues with your app.

Here's what you could do:

  1. Arrange 2 images (1 for the clear image and the other for the maximum blur version) so that the blur image is placed exactly on top of the clear image. The easiest way would be placing 2 ImageViews in a FrameLayout
  2. To achieve the "slow" blur effect, initially set the blur image's alpha to 0.
  3. Then, using one of the view, issue a postDelayed event to slowly increase the blur image's alpha to 255.