android bitmap blur,GitHub - psujug/android-stackblur: Android StackBlur is a library that can perfo...

Android StackBlur

Android StackBlur is a library that can perform a blurry effect on a Bitmap based on a gradient or radius, and return the result. The library is based on the code of Mario Klingemann.

The library is compatible for Android versions 1.5 (so pretty much compatible with every device).

A library and a sample application are provided with the code.

5ddbff5c04a82bf38c115a191a54ead3.png

68747470733a2f2f7261772e6769746875622e636f6d2f6b696b6f736f2f616e64726f69642d737461636b626c75722f6d61737465722f6172742f73637265656e73686f74322e706e67

Acknowledgements

Mario Klingemann developed the original algorithm and gave me the idea to port it to Android.

Manuel Peinado Gallego has generously pointed me out some other sources working on the same area.

Nicolas Pomepuy pointed me out to his really useful article on the topic.

Dr-Emann for his contribution adding RenderScript and Muiltithreding support.

Usage

Download the library with git. When it has been imported into your project. First initialize your StackBlurManager to load a sample image:

_stackBlurManager = new StackBlurManager(getBitmapFromAsset(this, "android_platform_256.png"));

Process using a certain radius with the following line:

_stackBlurManager.process(progress*5);

and finally obtain the image and load it into an ImageView or any other component:

_imageView.setImageBitmap(_stackBlurManager.returnBlurredImage() );

If you want to use the native code (NDK), first you need to compile the native files. Move to the folder where you have the project, and call:

ndk-build

If everything goes alright, you will compile and generate a library object, libblur.so, in the folder libs. For more information regarding the NDK framework, please click here. Then, from the code you just need to code:

_stackBlurManager.processNatively(progress*5);

The function processNatively(int radius) return the image already blurry. This code is 25-30 times faster as the Java code.

If you want to use RenderScript, you can do it by using:

_stackBlurManager.processRenderScript(progress*5);

Version history

10.02.2014: Added Multithreading support thanks to Dr-Emann

27.01.2014: Added Benchmarking, bug fixing thanks to Dr-Emann

10.01.2014: Added RenderScript support thanks to Dr-Emann

04.12.2013: Added support for NDK blurry, much faster.

02.12.2013: Solved the issue #1, provoking an ArrayOutOfBoundsException.

08.09.2013: Added support for Gradle

19.08.2013: Added support for Alpha blurring

Next steps

As soon as I get some free time I want to add the following features:

Uploading to MavenCentral

Support for PNG9

Unit tests

If you want to colaborate with the project, feel free to submit a pull request!

Also, if you have used Android StackBlur on your app and you let me know, I can link it from here :)

Developed By

9dd19e2c59e5a54cbdcd58991c536073.png

58eb5ec183ede882295fd7ccb7f639e1.png

b63e1a9b94fa3074ab37b6db19d9a676.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值