Coder Social home page Coder Social logo

easyblur's Introduction

EasyBlur

EasyBlur 是对RenderScript 和fastBlur 2种方法的包装。 使用RenderScript 和fastBlur 做图片的高斯模糊,默认使用RenderScript,可以通过属性设置使用fastBlur方式。

效果图:

效果图

Gradle依赖

1, 最外层build.gradle 添加一下代码:

allprojects {
    repositories {
        jcenter()
        
        maven {url "https://jitpack.io"}
    }
}

2,app 的build.gradle添加:

  dependencies {
  compile 'com.github.pinguo-zhouwei:EasyBlur:v1.0.0'
}

3,app 的build.gradle添加:

 defaultConfig {
        applicationId "com.zhouwei.easyblur"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
         
        //使用renderscript 兼容包 
        renderscriptTargetApi 25
        renderscriptSupportModeEnabled true
    }

使用方法

1,简单使用,指定Bitmap和半径

Bitmap finalBitmap = EasyBlur.with(MainActivity.this)
                        .bitmap(overlay) //要模糊的图片
                        .radius(10)//模糊半径
                        .blur();

2,可以指定缩小的倍数,默认缩小倍数为8

Bitmap finalBitmap = EasyBlur.with(MainActivity.this)
                        .bitmap(overlay) //要模糊的图片
                        .radius(10)//模糊半径
                        .scale(4)//指定模糊前缩小的倍数
                        .blur();

3, 指定使用哪一种方法,默认是使用兼容的RenderScript 高斯模糊

Bitmap finalBitmap = EasyBlur.with(MainActivity.this)
                        .bitmap(overlay) //要模糊的图片
                        .radius(10)//模糊半径
                        .scale(4)//指定模糊前缩小的倍数
                        .policy(EasyBlur.BlurPolicy.FAST_BLUR)//使用fastBlur
                        .blur();

博客

easyblur's People

Contributors

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