Coder Social home page Coder Social logo

android-stackblur's Introduction

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.

Example Image Example Image

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.

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.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:

  • Add support for RenderScript
  • Multithreading
  • Support for PNG9

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

Developed By

Enrique López Mañas - [email protected]

Follow me on Twitter Follow me on Google+ Follow me on LinkedIn

android-stackblur's People

Contributors

dr-emann avatar kikoso avatar

Watchers

 avatar

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.